https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124368
Bug ID: 124368
Summary: [reflection] bogus errors with meta::extent
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: mpolacek at gcc dot gnu.org
Target Milestone: ---
Compiling
```
#include <meta>
using T = int[extent(^^int[4])];
constexpr auto n = extent(^^int[4]);
static_assert (n == 4);
```
results in many errors:
extent1.C:3:21: error: size of array is not an integral constant-expression
3 | using T = int[extent(^^int[4])];
| ~~~~~~^~~~~~~~~~
extent1.C:4:35: error: ‘std::meta::extent(^^int [4], 0)’ is not a constant
expression because it initializes a ‘std::size_t’ {aka ‘long unsigned int’}
rather than ‘long unsigned int’
4 | constexpr auto n = extent(^^int[4]);
| ^
extent1.C:4:26: error: call to consteval function ‘std::meta::extent(^^int [4],
0)’ is not a constant expression
4 | constexpr auto n = extent(^^int[4]);
| ~~~~~~^~~~~~~~~~
extent1.C:4:35: error: ‘std::meta::extent(^^int [4], 0)’ is not a constant
expression because it initializes a ‘std::size_t’ {aka ‘long unsigned int’}
rather than ‘std::size_t’ {aka ‘long unsigned int’}
4 | constexpr auto n = extent(^^int[4]);
| ^
extent1.C:5:18: error: non-constant condition for static assertion
5 | static_assert (n == 4);
| ~~^~~~
extent1.C:5:16: error: the value of ‘n’ is not usable in a constant expression
5 | static_assert (n == 4);
| ^
extent1.C:4:16: note: ‘n’ used in its own initializer
4 | constexpr auto n = extent(^^int[4]);
| ^
extent1.C: In function ‘void __static_initialization_and_destruction_0()’:
extent1.C:4:26: error: call to consteval function ‘std::meta::extent(^^int [4],
0)’ is not a constant expression
4 | constexpr auto n = extent(^^int[4]);
| ~~~~~~^~~~~~~~~~
extent1.C:5:23: error: ‘std::meta::extent(^^int [4], 0)’ is not a constant
expression because it initializes a ‘std::size_t’ {aka ‘long unsigned int’}
rather than ‘std::size_t’ {aka ‘long unsigned int’}
5 | static_assert (n == 4);
| ^
extent1.C:4:29: error: consteval-only expressions are only allowed in a
constant-evaluated context
4 | constexpr auto n = extent(^^int[4]);
| ^~~