[clang] [Clang] Fixed an assertion in constant evaluation of EmbedExpr inside array initializers. (PR #182257)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 19 14:53:08 PST 2026
================
@@ -13,3 +14,37 @@ int *p2 = (int[]){
int *p3 = (int[30]){
#embed __FILE__ limit(30)
};
+
+
+#ifdef NEGATIVE
+
+// Pointer element type
+char *bad_ptr = (int (*[5]) 0){ // expected-error {{expected ')'}}
+ // expected-note at -1 {{to match this '('}}
+// expected-error at -2 {{incompatible pointer types initializing}}
+// expected-error at -3 {{initializer element is not a compile-time constant}}
+#embed __FILE__
+// expected-error at -1 {{incompatible integer to pointer conversion}}
+// expected-warning at -2 {{excess elements in array initializer}}
+};
----------------
efriedma-quic wrote:
```suggestion
void *bad_ptr = (int*[]){
#embed __FILE__ // expected-error {{incompatible integer to pointer conversion}}
};
```
https://github.com/llvm/llvm-project/pull/182257
More information about the cfe-commits
mailing list