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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
It is the instantiation_dependent_r hunk in pt.c that breaks this:
@@ -25361,7 +25486,10 @@
       return NULL_TREE;

     case TEMPLATE_PARM_INDEX:
-      return *tp;
+      if (dependent_type_p (TREE_TYPE (*tp)))
+       return *tp;
+      /* We'll check value-dependence separately.  */
+      return NULL_TREE;

       /* Handle expressions with type operands.  */
     case SIZEOF_EXPR:
which got later changed to:
    case TEMPLATE_PARM_INDEX:
      if (dependent_type_p (TREE_TYPE (*tp)))
        return *tp;
      if (TEMPLATE_PARM_PARAMETER_PACK (*tp))
        return *tp;
      /* We'll check value-dependence separately.  */
      return NULL_TREE;
If I return *tp; unconditionally, the testcase is accepted again.
This is called from:
#0  instantiation_dependent_r (tp=0x7fffffffb308, walk_subtrees=0x7fffffffb23c)
at ../../gcc/cp/pt.c:25945
#1  0x000000000183b7e9 in walk_tree_1 (tp=0x7fffffffb308, func=0xb1e156
<instantiation_dependent_r(tree*, int*, void*)>, data=0x0, 
    pset=0x7fffffffb2a0, 
    lh=0xb8e1ca <cp_walk_subtrees(tree_node**, int*, tree_node*
(*)(tree_node**, int*, void*), void*, hash_set<tree_node*,
default_hash_traits<tree_node*> >*)>) at ../../gcc/tree.c:12110
#2  0x000000000183cf41 in walk_tree_without_duplicates_1 (tp=0x7fffffffb308,
func=0xb1e156 <instantiation_dependent_r(tree*, int*, void*)>, 
    data=0x0, 
    lh=0xb8e1ca <cp_walk_subtrees(tree_node**, int*, tree_node*
(*)(tree_node**, int*, void*), void*, hash_set<tree_node*,
default_hash_traits<tree_node*> >*)>) at ../../gcc/tree.c:12458
#3  0x0000000000b1e5e6 in instantiation_dependent_uneval_expression_p
(expression=<template_parm_index 0x7fffea960210>) at ../../gcc/cp/pt.c:26042
#4  0x0000000000b7584e in finish_decltype_type (expr=<template_parm_index
0x7fffea960210>, id_expression_or_member_access_p=true, complain=3)
    at ../../gcc/cp/semantics.c:9363
#5  0x0000000000a5b330 in cp_parser_decltype (parser=0x7ffff7ffbab0) at
../../gcc/cp/parser.c:14688
and for finish_decltype_type nothing is asking about value-dependence I guess.

Reply via email to