[clang] [clang][bytecode] Catch placement-new into invalid destination (PR #164804)
Shafik Yaghmour via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 17 11:24:38 PST 2025
================
@@ -494,3 +494,32 @@ constexpr int modify_const_variable() {
}
static_assert(modify_const_variable()); // both-error {{not an integral constant expression}} \
// both-note {{in call to}}
+
+constexpr int nullDest() {
+ new (nullptr) int{12}; // both-note {{construction of dereferenced null pointer}}
+ return 0;
+}
+static_assert(nullDest() == 0); // both-error {{not an integral constant expression}} \
+ // both-note {{in call to}}
+
+constexpr int nullArrayDest() {
+ new (nullptr) int{12}; // both-note {{construction of dereferenced null pointer}}
----------------
shafik wrote:
It looks like you intended to make this an array but did not.
https://github.com/llvm/llvm-project/pull/164804
More information about the cfe-commits
mailing list