Skip to content

Commit 0de12bb

Browse files
authored
[clang][bytecode] Only block pointers can be partially initialized (#160075)
So ignore the rest in `checkFullyInitialized()`. Fixes #160071
1 parent 1132e82 commit 0de12bb

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

clang/lib/AST/ByteCode/EvaluationResult.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ bool EvaluationResult::checkFullyInitialized(InterpState &S,
133133

134134
if (Ptr.isZero())
135135
return true;
136+
if (!Ptr.isBlockPointer())
137+
return true;
136138

137139
// We can't inspect dead pointers at all. Return true here so we can
138140
// diagnose them later.

clang/test/AST/ByteCode/typeid.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ static_assert(&typeid(int) < &typeid(long)); // both-error {{not an integral con
3232
static_assert(&typeid(int) > &typeid(long)); // both-error {{not an integral constant expression}} \
3333
// both-note {{comparison between pointers to unrelated objects '&typeid(int)' and '&typeid(long)' has unspecified value}}
3434

35-
struct Base {
36-
virtual void func() ;
37-
};
38-
struct Derived : Base {};
35+
struct Base {
36+
virtual void func() ;
37+
};
38+
struct Derived : Base {};
3939

4040
constexpr bool test() {
4141
Derived derived;
@@ -52,3 +52,10 @@ int dontcrash() {
5252
);
5353
return pti.__flags == 0 ? 1 : 0;
5454
}
55+
56+
namespace TypeidPtrInEvaluationResult {
57+
struct C {};
58+
C c = C();
59+
consteval const std::type_info *ftype_info() { return &typeid(c); }
60+
const std::type_info *T1 = ftype_info();
61+
}

0 commit comments

Comments
 (0)