[clang] [clang] Reject initializing constexpr struct/union types with compound literals that contain non null pointers (PR #228776)
Abdulmalek Almkainzi via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 7 12:55:47 PDT 2026
================
@@ -470,3 +470,20 @@ struct S2 {
const struct S2 s2[2] = {{{"foo"}, 1}, [0].L[2] = 'x'}; // expected-warning {{initializer partially overrides prior initialization of this subobject}} \
// expected-note {{previous initialization is here}}
static_assert(s2[0].L[2] == 'x');// expected-warning {{folding it to a constant is a GNU extension}}
+
+// gh121694
+const int a = 0;
+struct C { const int *p; };
+constexpr struct C c1 = {&a}; // expected-error{{constexpr pointer initializer is not null}}
----------------
aalmkainzi wrote:
I've undo-ed the value dependent commit and made a separate issue for it https://github.com/llvm/llvm-project/issues/229888
https://github.com/llvm/llvm-project/pull/228776
More information about the cfe-commits
mailing list