Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang/lib/AST/ByteCode/Interp.h
Original file line number Diff line number Diff line change
Expand Up @@ -2258,6 +2258,8 @@ std::optional<Pointer> OffsetHelper(InterpState &S, CodePtr OpPC,
S.CCEDiag(S.Current->getSource(OpPC), diag::note_constexpr_array_index)
<< N << /*non-array*/ true << 0;
return Pointer(Ptr.asFunctionPointer().getFunction(), N);
} else if (!Ptr.isBlockPointer()) {
return std::nullopt;
}

assert(Ptr.isBlockPointer());
Expand Down
7 changes: 5 additions & 2 deletions clang/test/AST/ByteCode/typeid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,12 @@ namespace TypeidPtrInEvaluationResult {
// Regression test for crash in ArrayElemPtrPop with typeid pointers. GH-163127
namespace TypeidPtrRegression {
void dontcrash() {
// this should just be an error and not an ICE
constexpr auto res = ((void**)&typeid(int))[0]; // both-error {{must be initialized by a constant expression}} \
// both-note {{cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression}}
// both-note {{cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression}}
}
void dontcrash2() {
constexpr auto res = ((void**)&typeid(int))[1]; // both-error {{must be initialized by a constant expression}} \
// both-note {{cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression}}
}
}