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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
#include <meta>

template <typename T>
void
foo (int a)
{
  constexpr auto b = parameters_of (^^foo <int>)[0];
  constexpr auto c = identifier_of (type_of (b));
}

void
bar (int a)
{
  foo <int> (a);
}

So, we seem to have too many PARM_DECLs around, one is created for the ^^foo
<int>
case in
#5  0x00000000007f405c in tsubst_decl (t=<parm_decl 0x7fffe6236880 a>,
args=<tree_vec 0x7fffe623f800>, complain=0, use_spec_table=true) at
../../gcc/cp/pt.cc:15755
#6  0x00000000007f9b84 in tsubst (t=<parm_decl 0x7fffe6236880 a>,
args=<tree_vec 0x7fffe623f800>, complain=0, in_decl=<function_decl
0x7fffe6232800 foo>) at ../../gcc/cp/pt.cc:16871
#7  0x00000000007ed3b2 in tsubst_function_decl (t=<function_decl 0x7fffe6232800
foo>, args=<tree_vec 0x7fffe623f800>, complain=0, lambda_fntype=<tree 0x0>,
use_spec_table=false)
    at ../../gcc/cp/pt.cc:15191
#8  0x00000000007f3dc1 in tsubst_decl (t=<function_decl 0x7fffe6232800 foo>,
args=<tree_vec 0x7fffe623f800>, complain=0, use_spec_table=false) at
../../gcc/cp/pt.cc:15701
#9  0x0000000000821efc in instantiate_template (tmpl=<template_decl
0x7fffe6236908 foo>, orig_args=<tree_vec 0x7fffe623f800>, complain=0) at
../../gcc/cp/pt.cc:23477
#10 0x0000000000827f77 in resolve_nondeduced_context
(orig_expr=<template_id_expr 0x7fffe6240230>, complain=3) at
../../gcc/cp/pt.cc:25143
#11 0x00000000008281fa in resolve_nondeduced_context_or_error
(exp=<template_id_expr 0x7fffe6240230>, complain=3) at ../../gcc/cp/pt.cc:25187
#12 0x000000000085f1a8 in get_reflection (loc=3155380482, t=<template_id_expr
0x7fffe6240230>, kind=REFLECT_UNDEF) at ../../gcc/cp/reflect.cc:216
and another one later on
#5  0x00000000007f405c in tsubst_decl (t=<parm_decl 0x7fffe6236880 a>,
args=<tree_vec 0x7fffe623f800>, complain=1, use_spec_table=true) at
../../gcc/cp/pt.cc:15755
#6  0x0000000000834eba in regenerate_decl_from_template (decl=<function_decl
0x7fffe6232900 foo>, tmpl=<template_decl 0x7fffe6236908 foo>, args=<tree_vec
0x7fffe623f800>)
    at ../../gcc/cp/pt.cc:28035
#7  0x0000000000836900 in instantiate_body (pattern=<template_decl
0x7fffe6236908 foo>, args=<tree_vec 0x7fffe623f800>, d=<function_decl
0x7fffe6232900 foo>, nested_p=false)
    at ../../gcc/cp/pt.cc:28380
#8  0x0000000000838b19 in instantiate_decl (d=<function_decl 0x7fffe6232900
foo>, defer_ok=false, expl_inst_class_mem_p=false) at ../../gcc/cp/pt.cc:28738
The reflection refers to the former one, but DECL_CHAIN of its DECL_CONTEXT
containts the latter one, so eval_type_of loop then can't find it:
2449          tree args = FUNCTION_FIRST_USER_PARM (fn);
2450          tree type = FUNCTION_FIRST_USER_PARMTYPE (fn);
2451          while (r != args)
2452            {
2453              args = DECL_CHAIN (args);
2454              type = TREE_CHAIN (type);
2455            }
2456          r = TREE_VALUE (type);

Reply via email to