Bug 77339 - [5/6/7 Regression] ICE on invalid C++ code on x86_64-linux-gnu: in cp_parser_type_name, at cp/parser.c:16532
Summary: [5/6/7 Regression] ICE on invalid C++ code on x86_64-linux-gnu: in cp_parser_...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.0
: P2 normal
Target Milestone: 7.0
Assignee: Jason Merrill
URL:
Keywords: ice-on-invalid-code
: 58987 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-08-23 07:01 UTC by Zhendong Su
Modified: 2017-03-31 21:09 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.7.4
Known to fail:
Last reconfirmed: 2016-08-23 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zhendong Su 2016-08-23 07:01:08 UTC
It affects 4.8.x and later, and is a regression from 4.7.x.


$ 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 20160822 (experimental) [trunk revision 239655] (GCC) 
$ 
$ g++-trunk -c small.cpp
small.cpp:3:25: internal compiler error: in cp_parser_type_name, at cp/parser.c:16532
 template < typename X > A < X >::a;
                         ^~~~~~~
0x7a94ec cp_parser_type_name
	../../gcc-source-trunk/gcc/cp/parser.c:16532
0x797f89 cp_parser_type_name
	../../gcc-source-trunk/gcc/cp/parser.c:16482
0x797f89 cp_parser_simple_type_specifier
	../../gcc-source-trunk/gcc/cp/parser.c:16396
0x793e71 cp_parser_type_specifier
	../../gcc-source-trunk/gcc/cp/parser.c:16049
0x7a8d33 cp_parser_decl_specifier_seq
	../../gcc-source-trunk/gcc/cp/parser.c:12889
0x7b7d15 cp_parser_single_declaration
	../../gcc-source-trunk/gcc/cp/parser.c:25934
0x7b808c cp_parser_template_declaration_after_parameters
	../../gcc-source-trunk/gcc/cp/parser.c:25630
0x7b8aa1 cp_parser_explicit_template_declaration
	../../gcc-source-trunk/gcc/cp/parser.c:25861
0x7b8aa1 cp_parser_template_declaration_after_export
	../../gcc-source-trunk/gcc/cp/parser.c:25879
0x7c00e9 cp_parser_declaration
	../../gcc-source-trunk/gcc/cp/parser.c:12209
0x7beb34 cp_parser_declaration_seq_opt
	../../gcc-source-trunk/gcc/cp/parser.c:12139
0x7bee78 cp_parser_translation_unit
	../../gcc-source-trunk/gcc/cp/parser.c:4356
0x7bee78 c_parse_file()
	../../gcc-source-trunk/gcc/cp/parser.c:37671
0x92c462 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.
$ 


-------------------------------------------


template < typename > using A = int;

//OK: template < typename X > A < X > a; 
template < typename X > A < X >::a;
Comment 1 Marek Polacek 2016-08-23 11:42:14 UTC
Confirmed.
Comment 2 Marek Polacek 2016-08-23 11:52:04 UTC
I'm pretty sure this started with r181118:

commit 370478b178a3bdf01988c16782c90add8aea26aa
Author: dodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Mon Nov 7 21:28:50 2011 +0000

    PR c++/45114 - Support C++11 alias-declaration
Comment 3 Marek Polacek 2016-08-23 11:55:37 UTC
clang++ says
w.C:4:25: error: type 'A<X>' (aka 'int') cannot be used prior to '::' because it has no members
template < typename X > A < X >::a;
                        ^
w.C:1:23: note: type alias template 'A' declared here
template < typename > using A = int;
                      ^
1 error generated.
Comment 4 Jason Merrill 2017-03-24 14:40:45 UTC
Author: jason
Date: Fri Mar 24 14:40:13 2017
New Revision: 246462

URL: https://gcc.gnu.org/viewcvs?rev=246462&root=gcc&view=rev
Log:
	PR c++/77339 - ICE with invalid use of alias template.

	* pt.c (lookup_template_class_1): Don't try to enter the scope of an
	alias template.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/alias-decl-58.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
Comment 5 Jason Merrill 2017-03-27 16:07:37 UTC
Fixed for GCC 7.
Comment 6 Volker Reichelt 2017-03-31 21:09:44 UTC
*** Bug 58987 has been marked as a duplicate of this bug. ***