https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77639
Bug ID: 77639 Summary: ICE on x86_64-linux-gnu (internal compiler error: tree check: accessed elt 1 of tree_vec with 0 elts in unify, at cp/pt.c:19674) Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: chengniansun at gmail dot com Target Milestone: --- $ g++-trunk -v Using built-in specs. COLLECT_GCC=g++-trunk COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-source-trunk/configure --enable-languages=c,c++,lto --prefix=/usr/local/gcc-trunk --disable-bootstrap Thread model: posix gcc version 7.0.0 20160918 (experimental) [trunk revision 240220] (GCC) $ $ g++-trunk small.C small.C:2:35: error: an explicit specialization must be preceded by ‘template <>’ template <class T, int a, class U struct B<T, a, U, 1> {}; ^~~~~~~~~~~~~~~~~~~~ template <> small.C:2:42: error: enclosing class templates are not explicitly specialized template <class T, int a, class U struct B<T, a, U, 1> {}; ^~~~~~~~~~~~~ small.C:2:56: error: types may not be defined in parameter types template <class T, int a, class U struct B<T, a, U, 1> {}; ^ small.C:2:56: error: definition of ‘struct B<T, a, U, 1>’ inside template parameter list small.C:2:57: error: two or more data types in declaration of ‘parameter’ template <class T, int a, class U struct B<T, a, U, 1> {}; ^ small.C:2:58: error: expected ‘>’ before ‘;’ token template <class T, int a, class U struct B<T, a, U, 1> {}; ^ small.C:2:58: error: expected unqualified-id before ‘;’ token small.C:3:20: internal compiler error: tree check: accessed elt 1 of tree_vec with 0 elts in unify, at cp/pt.c:19674 B<int, 2, char, 1> i; ^ 0x107f2b5 tree_vec_elt_check_failed(int, int, char const*, int, char const*) ../../gcc-source-trunk/gcc/tree.c:9939 0x6f2572 tree_vec_elt_check ../../gcc-source-trunk/gcc/tree.h:3247 0x6f2572 unify ../../gcc-source-trunk/gcc/cp/pt.c:19674 0x6f1915 unify ../../gcc-source-trunk/gcc/cp/pt.c:20081 0x6f4156 get_partial_spec_bindings ../../gcc-source-trunk/gcc/cp/pt.c:20851 0x6eb961 most_specialized_partial_spec ../../gcc-source-trunk/gcc/cp/pt.c:21107 0x707005 instantiate_class_template_1 ../../gcc-source-trunk/gcc/cp/pt.c:9848 0x707005 instantiate_class_template(tree_node*) ../../gcc-source-trunk/gcc/cp/pt.c:10416 0x7adbcb complete_type(tree_node*) ../../gcc-source-trunk/gcc/cp/typeck.c:133 0x66b315 start_decl_1(tree_node*, bool) ../../gcc-source-trunk/gcc/cp/decl.c:5168 0x6944bf start_decl(cp_declarator const*, cp_decl_specifier_seq*, int, tree_node*, tree_node*, tree_node**) ../../gcc-source-trunk/gcc/cp/decl.c:5131 0x79a089 cp_parser_init_declarator ../../gcc-source-trunk/gcc/cp/parser.c:18701 0x79aae7 cp_parser_simple_declaration ../../gcc-source-trunk/gcc/cp/parser.c:12495 0x79ae66 cp_parser_block_declaration ../../gcc-source-trunk/gcc/cp/parser.c:12363 0x7a3d14 cp_parser_declaration ../../gcc-source-trunk/gcc/cp/parser.c:12260 0x7a28af cp_parser_declaration_seq_opt ../../gcc-source-trunk/gcc/cp/parser.c:12139 0x7a2bf8 cp_parser_translation_unit ../../gcc-source-trunk/gcc/cp/parser.c:4356 0x7a2bf8 c_parse_file() ../../gcc-source-trunk/gcc/cp/parser.c:37714 0x917b92 c_common_parse_file() ../../gcc-source-trunk/gcc/c-family/c-opts.c:1073 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. $ $ cat small.C template <class, int, class, int> struct B {}; template <class T, int a, class U struct B<T, a, U, 1> {}; B<int, 2, char, 1> i; $