https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123662
Bug ID: 123662
Summary: [reflection] Unexpected "error: consteval-only
expressions are only allowed in a constant-evaluated
context"
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: boris.staletic at protonmail dot com
Target Milestone: ---
Created attachment 63377
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=63377&action=edit
Preprocessed snippet
This snippet
```
#include <meta>
struct arg {
std::meta::info name;
bool none = true;
};
template<size_t...Is>
void test1() {
constexpr auto py_arg_data =
std::array{arg{std::meta::reflect_constant_string("_")}};
constexpr auto short_py_arg_data = [:
std::meta::reflect_constant_array(py_arg_data) :];
}
```
Errors with
```
example.cpp:11:76: error: consteval-only expressions are only allowed in a
constant-evaluated context
11 | constexpr auto short_py_arg_data = [:
std::meta::reflect_constant_array(py_arg_data) :];
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
Compiler returned: 1
```
The `reflect_static_array` is called from within a splice expression, so it is
certainly a constant-evaluated context.