Skip to content

Commit 0076d68

Browse files
committed
[clang][Interp] Add regression test for crash with typeid pointers
1 parent 7e74074 commit 0076d68

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

clang/test/AST/ByteCode/typeid.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,13 @@ namespace TypeidPtrInEvaluationResult {
5959
consteval const std::type_info *ftype_info() { return &typeid(c); }
6060
const std::type_info *T1 = ftype_info();
6161
}
62+
63+
// Regression test for crash in ArrayElemPtrPop with typeid pointers. GH-163127
64+
namespace TypeidPtrRegression {
65+
void dontcrash() {
66+
// this should just be an error and not an ICE
67+
constexpr auto res = ((void**)&typeid(int))[0]; // both-error {{must be initialized by a constant expression}} \
68+
// both-note {{cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression}}
69+
}
70+
}
71+

0 commit comments

Comments
 (0)