[PATCH] D123649: Allow flexible array initialization in C++.
Eli Friedman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 13 12:31:31 PDT 2022
efriedma added inline comments.
================
Comment at: clang/test/SemaCXX/constant-expression-cxx11.cpp:2388
+ // evaluation. Make sure we emit a sane error message, for now.
+ constexpr A c = {1, 2, 3}; // expected-warning {{flexible array initialization is a GNU extension}}
+ static_assert(c.arr[0] == 1, ""); // expected-error {{constant expression}} expected-note {{array member without known bound}}
----------------
erichkeane wrote:
> I would expect this to be an error, not the static-assert. The constexpr variable means 'initializable as a constant expression'.
>
> I'm guessing the problem is ACTUALLY that we support constexpr init, but not the operator[]. I think I'd like to have us have the initialization fail here, since it isn't otherwise usable.
I think we end up computing the initializer "correctly", but have no way to actually access the elements in constant evaluation. Seems to come out of CGExprConstant lowering okay, but I guess we don't really need that to work at the moment; we fall back to the old CGExprConstant direct lowering code.
I'll add a bailout to constant evaluation.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D123649/new/
https://reviews.llvm.org/D123649
More information about the cfe-commits
mailing list