Skip to content
Open
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
4 changes: 4 additions & 0 deletions clang/lib/AST/ByteCode/Interp.h
Original file line number Diff line number Diff line change
Expand Up @@ -2191,6 +2191,8 @@ bool Store(InterpState &S, CodePtr OpPC) {
const Pointer &Ptr = S.Stk.peek<Pointer>();
if (!CheckStore(S, OpPC, Ptr))
return false;
if (!Ptr.canDeref(Name))
return false;
if (Ptr.canBeInitialized())
Ptr.initialize();
Ptr.deref<T>() = Value;
Expand All @@ -2203,6 +2205,8 @@ bool StorePop(InterpState &S, CodePtr OpPC) {
const Pointer &Ptr = S.Stk.pop<Pointer>();
if (!CheckStore(S, OpPC, Ptr))
return false;
if (!Ptr.canDeref(Name))
return false;
if (Ptr.canBeInitialized())
Ptr.initialize();
Ptr.deref<T>() = Value;
Expand Down
9 changes: 9 additions & 0 deletions clang/test/AST/ByteCode/cxx20.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1404,3 +1404,12 @@ namespace InvalidOMPRequiredSimdAlign {
typedef decltype(sizeof(int)) T;
constexpr T foo(T x) { return __builtin_omp_required_simd_align * 42; } // both-error {{indirection requires pointer operand}}
}

namespace StoreCannotDeref {
constexpr void foo() { // both-error {{never produces a constant expression}}
int l = 10;
int *n = &l;
int *m = (int *)&n; // both-note {{cast that performs the conversions of a reinterpret_cast}}
*m = 42;
}
}
Loading