================ @@ -849,13 +849,11 @@ namespace CompoundLiterals { } static_assert(get5() == 5, ""); - constexpr int get6(int f = (int[]){1,2,6}[2]) { // ref-note {{subexpression not valid in a constant expression}} \ - // ref-note {{declared here}} + constexpr int get6(int f = (int[]){1,2,6}[2]) { ---------------- AaronBallman wrote:
Thanks, I'll add more tests. > `constinit int* a1 = f(); // error: pointer points to local variable` Yes, this should fail (and it does). > `constexpr int f2(int *x, int (*y)[*(x=(int[]){1,2,3})]) {` You are a bad person who should feel bad. :-D I do think that should evaluate to 1 (but only when calling `f2(0)`), but that's a pile of VLA code which we don't always handle well, especially in C++. I think a non-VLA example that's similar would be: ``` constexpr int f2(int *x =(int[]){1,2,3}) { return x[0]; } constexpr int g = f2(); // Should evaluate to 1? static_assert(g == 1, ""); ``` which does behave how you'd expect. The VLA example says `object backing the pointer x will be destroyed at the end of the full-expression` which may be a C++'ism not impacted by the C wording? https://github.com/llvm/llvm-project/pull/132097 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits