Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion clang/lib/AST/ByteCode/Interp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,8 @@ bool CheckConst(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {

// The This pointer is writable in constructors and destructors,
// even if isConst() returns true.
if (llvm::find(S.InitializingBlocks, Ptr.block()))
if (llvm::find(S.InitializingBlocks, Ptr.block()) !=
S.InitializingBlocks.end())
return true;

const QualType Ty = Ptr.getType();
Expand Down
8 changes: 8 additions & 0 deletions clang/test/AST/ByteCode/placement-new.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,3 +486,11 @@ namespace bitcast {
}
static_assert(foo() == 0);
}

constexpr int modify_const_variable() {
const int a = 10;
new ((int *)&a) int(12); // both-note {{modification of object of const-qualified type 'const int' is not allowed in a constant expression}}
return a;
}
static_assert(modify_const_variable()); // both-error {{not an integral constant expression}} \
// both-note {{in call to}}
1 change: 1 addition & 0 deletions clang/test/SemaCXX/cxx2c-constexpr-placement-new.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -std=c++2c -verify %s
// RUN: %clang_cc1 -std=c++2c -verify %s -fexperimental-new-constant-interpreter


namespace std {
Expand Down
Loading