https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123612
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
With constexpr auto ret = ^^a; instead of auto ret = ^^a; it fails with
pr123612.C:13:20: error: static assertion failed
13 | static_assert(std::is_same_v<decltype(a),decltype([:f():])>);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
• ‘int []’ is not the same as ‘int [3]’
and I think that is perfectly fine, a inside of the function has int[3] type
while a outside of it has int[] type. Or do you think that
static_assert(^^a == f());
should pass too?
With just auto ret = ^^a; we error:
pr123612.C: In function ‘consteval auto f()’:
pr123612.C:10:55: error: the value of ‘ret’ is not usable in a constant
expression
10 | static_assert(std::is_same_v<decltype(a),decltype([:ret:])>);
| ^~~
pr123612.C:9:8: note: ‘ret’ was not declared ‘constexpr’
9 | constexpr auto ret = ^^a;
| ^~~
and I think that is correct too, ret is an automatic variable non-constexpr
variable (fine from the POV that it is consteval-only because it is in
immediate function, but not from the POV of static_assert).