https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123611

--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
For #c0, the backtrace for error_at is:
#11 0x00000000031a3ff6 in error_at (loc=4611686018427410884, gmsgid=0x3f280f0
"consteval-only expressions are only allowed in a constant-evaluated context")
    at ../../gcc/diagnostic-global-context.cc:655
#12 0x000000000087eeea in check_out_of_consteval_use (expr=<preincrement_expr
0x7fffe1ac0cd0>, complain=true) at ../../gcc/cp/reflect.cc:8199
#13 0x00000000005140fa in convert_to_void (expr=<preincrement_expr
0x7fffe1ac0cd0>, implicit=ICV_STATEMENT, complain=3) at
../../gcc/cp/cvt.cc:1219
#14 0x0000000000894fff in finish_expr_stmt (expr=<preincrement_expr
0x7fffe1ac0cd0>) at ../../gcc/cp/semantics.cc:1180
#15 0x00000000005fed04 in build_vec_init (base=<var_decl 0x7fffe1aa3980>,
maxindex=<integer_cst 0x7fffe8a59138>, init=<constructor 0x7fffe1ac6b28>,
explicit_value_init_p=false, 
    from_array=0, complain=3, cleanup_flags=0x0) at ../../gcc/cp/init.cc:4957
#16 0x00000000005f421f in build_aggr_init (
    exp=<var_decl 0x7fffe1aa3850
_ZTAXtlA2_KSt4pairIDmDmEtlS0_tlSt11__pair_baseIDmDmEELDmdm4Args4nameELDmdm4Opts4nameEEtlS0_tlS4_ELDmdmS5_4nameELDmdmS6_4nameEEEE>,
 
    init=<constructor 0x7fffe1ac6b28>, flags=4, complain=3) at
../../gcc/cp/init.cc:2068
#17 0x000000000055dad8 in build_aggr_init_full_exprs (
    decl=<var_decl 0x7fffe1aa3850
_ZTAXtlA2_KSt4pairIDmDmEtlS0_tlSt11__pair_baseIDmDmEELDmdm4Args4nameELDmdm4Opts4nameEEtlS0_tlS4_ELDmdmS5_4nameELDmdmS6_4nameEEEE>,
 
    init=<constructor 0x7fffe1ac6b28>, flags=4) at ../../gcc/cp/decl.cc:8372
#18 0x000000000055e947 in check_initializer (
    decl=<var_decl 0x7fffe1aa3850
_ZTAXtlA2_KSt4pairIDmDmEtlS0_tlSt11__pair_baseIDmDmEELDmdm4Args4nameELDmdm4Opts4nameEEtlS0_tlS4_ELDmdmS5_4nameELDmdmS6_4nameEEEE>,
 
    init=<constructor 0x7fffe1ac6b28>, flags=4, cleanups=Python Exception
<class 'RuntimeError'>: Null type name.
0x7fffffff6c30) at ../../gcc/cp/decl.cc:8543
#19 0x0000000000567494 in cp_finish_decl (
    decl=<var_decl 0x7fffe1aa3850
_ZTAXtlA2_KSt4pairIDmDmEtlS0_tlSt11__pair_baseIDmDmEELDmdm4Args4nameELDmdm4Opts4nameEEtlS0_tlS4_ELDmdmS5_4nameELDmdmS6_4nameEEEE>,
 
    init=<constructor 0x7fffe1ac6b28>, init_const_expr_p=false,
asmspec_tree=<tree 0x0>, flags=4, decomp=0x0) at ../../gcc/cp/decl.cc:9880
#20 0x00000000006ebb92 in pushdecl_top_level_and_finish (
    x=<var_decl 0x7fffe1aa3850
_ZTAXtlA2_KSt4pairIDmDmEtlS0_tlSt11__pair_baseIDmDmEELDmdm4Args4nameELDmdm4Opts4nameEEtlS0_tlS4_ELDmdmS5_4nameELDmdmS6_4nameEEEE>,
 
    init=<constructor 0x7fffe1ac6b28>) at ../../gcc/cp/name-lookup.cc:9243
#21 0x00000000007c5e5a in get_template_parm_object (expr=<constructor
0x7fffe1ac6b28>, 
    name=<identifier_node 0x7fffe1a9b740
_ZTAXtlA2_KSt4pairIDmDmEtlS0_tlSt11__pair_baseIDmDmEELDmdm4Args4nameELDmdm4Opts4nameEEtlS0_tlS4_ELDmdmS5_4nameELDmdmS6_4nameEEEE>,
 
    check_init=true) at ../../gcc/cp/pt.cc:7561
#22 0x0000000000872e0d in eval_reflect_constant_array (loc=4611686018427410884,
ctx=0x7fffffff7700, call=<call_expr 0x7fffe1f13428>,
non_constant_p=0x7fffffff989f, 
    overflow_p=0x7fffffff989e, jump_target=0x7fffffff9040, fun=<function_decl
0x7fffe1ef5100 reflect_constant_array>) at ../../gcc/cp/reflect.cc:6174
#23 0x000000000087d217 in process_metafunction (ctx=0x7fffffff7700,
fun=<function_decl 0x7fffe1ef5100 reflect_constant_array>, call=<call_expr
0x7fffe1f13428>, 
    non_constant_p=0x7fffffff989f, overflow_p=0x7fffffff989e,
jump_target=0x7fffffff9040) at ../../gcc/cp/reflect.cc:7685

Marek, I'm afraid this needs your investigation, while it is deeper from
expansion statement evaluation, it is rejected equally if I do
      constexpr auto ctx = std::meta::access_context::current();
      constexpr auto a = std::define_static_array(
                      std::views::zip(nonstatic_data_members_of(^^Spec, ctx),
                                      nonstatic_data_members_of(^^Opts, ctx)) |
                      std::views::transform([](auto z) { return
std::pair(get<0>(z), get<1>(z)); }));

      return opts;
in the function instead.
Shall process_metafunction (or just for specific metafunctions or just parts
thereof) arrange for in_immediate_context ()?
E.g. using:
  in_consteval_if_p_temp_override icip;                                         
  in_consteval_if_p = true;                                                     
?

Reply via email to