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

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Perhaps slightly simpler testcase:
struct A {
  int &operator[] (int x) { return a[x]; };
  int a[2];
};

int
foo (A &x, int y)
{
  return [: ^^x :][y];
}

template <typename T>
int
bar (T &x, int y)
{
  return [: ^^x :][y];
}

int
baz (A &x, int y)
{
  return bar (x, y);
}

This shows that for the non-template case we call convert_from_reference:
#0  convert_from_reference (val=<parm_decl 0x7fffe9810e58 x>) at
../../gcc/cp/cvt.cc:538
#1  0x00000000008c63e5 in finish_id_expression_1 (id_expression=<parm_decl
0x7fffe9810e58 x>, decl=<parm_decl 0x7fffe9810e58 x>, scope=<tree 0x0>,
idk=0x7fffffffbaac, 
    integral_constant_expression_p=false,
allow_non_integral_constant_expression_p=true,
non_integral_constant_expression_p=0x7ffff7fba0fd, template_p=false, done=true, 
    address_p=false, template_arg_p=false, error_msg=0x7fffffffb490,
location=4611686018427387908) at ../../gcc/cp/semantics.cc:5270
#2  0x00000000008c64fc in finish_id_expression (id_expression=<parm_decl
0x7fffe9810e58 x>, decl=<parm_decl 0x7fffe9810e58 x>, scope=<tree 0x0>,
idk=0x7fffffffbaac, 
    integral_constant_expression_p=false,
allow_non_integral_constant_expression_p=true,
non_integral_constant_expression_p=0x7ffff7fba0fd, template_p=false, done=true, 
    address_p=false, template_arg_p=false, error_msg=0x7fffffffb490,
location=4611686018427387908) at ../../gcc/cp/semantics.cc:5300
#3  0x0000000000717079 in cp_parser_splice_expression (parser=0x7ffff7fba0d0,
template_p=false, address_p=false, template_arg_p=false, member_access_p=false,
idk=0x7fffffffbaac)
    at ../../gcc/cp/parser.cc:6406
but during instantiation we actually don't call it.
I think tsubst_splice_expr should do it, but maybe I'm wrong.

Reply via email to