Bug 77639 - [6 Regression] 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)
Summary: [6 Regression] ICE on x86_64-linux-gnu (internal compiler error: tree check: ...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.0
: P4 normal
Target Milestone: 7.0
Assignee: Patrick Palka
URL:
Keywords: error-recovery, ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2016-09-18 23:07 UTC by Chengnian Sun
Modified: 2018-10-26 11:20 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 5.4.0
Known to fail:
Last reconfirmed: 2016-09-19 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chengnian Sun 2016-09-18 23:07:57 UTC
$ 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;
$
Comment 1 Richard Biener 2016-09-19 07:31:25 UTC
GCC 5 doesn't ICE.
Comment 2 Jakub Jelinek 2016-09-19 10:01:38 UTC
Started with r225706.
Comment 3 Patrick Palka 2016-09-19 18:13:08 UTC
Author: ppalka
Date: Mon Sep 19 18:12:36 2016
New Revision: 240245

URL: https://gcc.gnu.org/viewcvs?rev=240245&root=gcc&view=rev
Log:
Fix PR c++/77639 (ICE during error recovery)

gcc/cp/ChangeLog:

	PR c++/77639
	* parser.c (cp_parser_class_head): When
	processing_template_parmlist, don't assume that the
	class-head may start an explicit specialization.

gcc/testsuite/ChangeLog:

	PR c++/77639
	* g++.dg/template/error-recovery4.C: New test.


Added:
    trunk/gcc/testsuite/g++.dg/template/error-recovery4.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog
Comment 4 Jakub Jelinek 2016-12-21 10:56:36 UTC
GCC 6.3 is being released, adjusting target milestone.
Comment 5 Richard Biener 2017-07-04 08:46:19 UTC
GCC 6.4 is being released, adjusting target milestone.
Comment 6 Jakub Jelinek 2018-10-26 11:20:20 UTC
GCC 6 branch is being closed, fixed in 7.x.