Skip to content

Commit cb6c0f1

Browse files
committed
[clang][Interp] Ignore ArrayDecay ops for null pointers
Just don't do anything and let later operations handle the diagnostics.
1 parent fdd60c7 commit cb6c0f1

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

clang/lib/AST/Interp/Interp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1933,7 +1933,7 @@ inline bool ArrayElemPop(InterpState &S, CodePtr OpPC, uint32_t Index) {
19331933
inline bool ArrayDecay(InterpState &S, CodePtr OpPC) {
19341934
const Pointer &Ptr = S.Stk.pop<Pointer>();
19351935

1936-
if (Ptr.isDummy()) {
1936+
if (Ptr.isZero() || Ptr.isDummy()) {
19371937
S.Stk.push<Pointer>(Ptr);
19381938
return true;
19391939
}

clang/test/AST/Interp/cxx11.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ struct S {
2828
};
2929
constexpr S s = { 5 };
3030
constexpr const int *p = &s.m + 1;
31+
32+
constexpr const int *np2 = &(*(int(*)[4])nullptr)[0]; // ok

0 commit comments

Comments
 (0)