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;
Confirmed.
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
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.
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
Fixed for GCC 7.
*** Bug 58987 has been marked as a duplicate of this bug. ***