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

            Bug ID: 86171
           Summary: g++  ICE on valid code: tree check: expected var_decl
                    or function_decl, have type_decl in duplicate_decls,
                    at cp/decl.c:2291
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: helloqirun at gmail dot com
  Target Milestone: ---

It appears to be a recent regression.

g++-8.1 compiles. g++-4.8 also compiles with "-std=c++11"


$ g++-trunk -v
Using built-in specs.
COLLECT_GCC=g++-trunk
COLLECT_LTO_WRAPPER=/home/absozero/trunk/root-gcc/libexec/gcc/x86_64-pc-linux-gnu/9.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --prefix=/home/absozero/trunk/root-gcc
--enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
gcc version 9.0.0 20180615 (experimental) [trunk revision 261626] (GCC)




$ g++-trunk abc.c
abc.c: In substitution of ‘template<class T> using B = typename A::A [with T =
short int]’:
abc.c:4:8:   required from here
abc.c:2:46: internal compiler error: tree check: expected var_decl or
function_decl, have type_decl in duplicate_decls, at cp/decl.c:2291
 template <class T> using B = typename A<T>::A;
                                              ^
0x78a200 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ../../gcc/gcc/tree.c:9336
0x88f372 tree_check2(tree_node*, char const*, int, char const*, tree_code,
tree_code)
        ../../gcc/gcc/tree.h:3136
0x88f372 duplicate_decls(tree_node*, tree_node*, bool)
        ../../gcc/gcc/cp/decl.c:2291
0x951389 register_specialization
        ../../gcc/gcc/cp/pt.c:1625
0x96a81e tsubst_decl
        ../../gcc/gcc/cp/pt.c:13778
0x95efe7 tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.c:14193
0x97b7f2 instantiate_template_1
        ../../gcc/gcc/cp/pt.c:19234
0x97b7f2 instantiate_template(tree_node*, tree_node*, int)
        ../../gcc/gcc/cp/pt.c:19290
0x95f38b instantiate_alias_template
        ../../gcc/gcc/cp/pt.c:19314
0x95f38b tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.c:14220
0x970637 lookup_template_class_1
        ../../gcc/gcc/cp/pt.c:9391
0x970637 lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int, int)
        ../../gcc/gcc/cp/pt.c:9646
0x9a069d finish_template_type(tree_node*, tree_node*, int)
        ../../gcc/gcc/cp/semantics.c:3240
0x91e0a4 cp_parser_template_id
        ../../gcc/gcc/cp/parser.c:15943
0x91e1a8 cp_parser_class_name
        ../../gcc/gcc/cp/parser.c:22478
0x92a90f cp_parser_qualifying_entity
        ../../gcc/gcc/cp/parser.c:6564
0x92a90f cp_parser_nested_name_specifier_opt
        ../../gcc/gcc/cp/parser.c:6250
0x933509 cp_parser_constructor_declarator_p
        ../../gcc/gcc/cp/parser.c:26629
0x933509 cp_parser_decl_specifier_seq
        ../../gcc/gcc/cp/parser.c:13694
0x938c7f cp_parser_simple_declaration
        ../../gcc/gcc/cp/parser.c:13015
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.


$ cat abc.c
template <class> struct A;
template <class T> using B = typename A<T>::A;
template <class T> struct A { typedef B<T> U; };
B<short> b;

Reply via email to