https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71827
Bug ID: 71827
Summary: ICE on invalid C++11 code with illegal non-type
template argument: in convert_nontype_argument, at
cp/pt.c:6014
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: su at cs dot ucdavis.edu
Target Milestone: ---
The following C++11 code causes an ICE when compiled with the current GCC trunk
on x86_64-linux-gnu in both 32-bit and 64-bit modes.
It seems to affect all versions since as early as 4.7.x (when C++11 started to
be supported).
$ 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 20160709 (experimental) [trunk revision 238191] (GCC)
$
$ g++-trunk -c small.cpp
small.cpp: In function ‘void foo()’:
small.cpp:5:41: internal compiler error: in convert_nontype_argument, at
cp/pt.c:6418
m: n: A < int, (long) &&n - (long) &&m > a;
^
0x6e8707 convert_nontype_argument
../../gcc-source-trunk/gcc/cp/pt.c:6418
0x6ef463 convert_template_argument
../../gcc-source-trunk/gcc/cp/pt.c:7287
0x6faa8b coerce_template_parms
../../gcc-source-trunk/gcc/cp/pt.c:7748
0x6fd7ea lookup_template_class_1
../../gcc-source-trunk/gcc/cp/pt.c:8331
0x6fd7ea lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int, int)
../../gcc-source-trunk/gcc/cp/pt.c:8672
0x81769d finish_template_type(tree_node*, tree_node*, int)
../../gcc-source-trunk/gcc/cp/semantics.c:3133
0x7a3ce4 cp_parser_template_id
../../gcc-source-trunk/gcc/cp/parser.c:14919
0x7a3f8a cp_parser_class_name
../../gcc-source-trunk/gcc/cp/parser.c:21223
0x7929ad cp_parser_qualifying_entity
../../gcc-source-trunk/gcc/cp/parser.c:6250
0x7929ad cp_parser_nested_name_specifier_opt
../../gcc-source-trunk/gcc/cp/parser.c:5934
0x7b0ead cp_parser_simple_type_specifier
../../gcc-source-trunk/gcc/cp/parser.c:16242
0x789c81 cp_parser_type_specifier
../../gcc-source-trunk/gcc/cp/parser.c:15919
0x7a4673 cp_parser_decl_specifier_seq
../../gcc-source-trunk/gcc/cp/parser.c:12763
0x7adc91 cp_parser_simple_declaration
../../gcc-source-trunk/gcc/cp/parser.c:12304
0x7ae0e1 cp_parser_block_declaration
../../gcc-source-trunk/gcc/cp/parser.c:12251
0x7aeb38 cp_parser_declaration_statement
../../gcc-source-trunk/gcc/cp/parser.c:11863
0x78d01b cp_parser_statement
../../gcc-source-trunk/gcc/cp/parser.c:10531
0x78d93c cp_parser_statement_seq_opt
../../gcc-source-trunk/gcc/cp/parser.c:10809
0x78da2f cp_parser_compound_statement
../../gcc-source-trunk/gcc/cp/parser.c:10763
0x7ac2cf cp_parser_function_body
../../gcc-source-trunk/gcc/cp/parser.c:20701
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 T, T > struct A {};
void foo ()
{
m: n: A < int, (long) &&n - (long) &&m > a;
}