https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84678
Bug ID: 84678
Summary: ICE on invalid code with nested templates
Product: gcc
Version: 8.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: benni.buch at gmail dot com
Target Milestone: ---
This was previously part of the Bug 72752 comment 11.
template< typename >
struct Outer{
template< typename >
struct Inner;
};
template<>
template< typename _T_ >
class Outer< _T_ >::Inner< _T_ >{};
template struct Outer< int >::Inner< int >;
Known to fail on GCC 5, 6, 7 and 8.
$ g++ -c main.cpp
main.cpp:9:21: internal compiler error: in retrieve_specialization, at
cp/pt.c:1191
class Outer< _T_ >::Inner< _T_ >{};
^~~~~~~~~~~~
0x605f2d retrieve_specialization
../../gcc/gcc/cp/pt.c:1188
0x9480dd tsubst_template_decl
../../gcc/gcc/cp/pt.c:12761
0x94495f tsubst_decl
../../gcc/gcc/cp/pt.c:12917
0x93e96f tsubst(tree_node*, tree_node*, int, tree_node*)
../../gcc/gcc/cp/pt.c:13809
0x9331ad most_specialized_partial_spec
../../gcc/gcc/cp/pt.c:22468
0x9567bf instantiate_class_template_1
../../gcc/gcc/cp/pt.c:10519
0x9567bf instantiate_class_template(tree_node*)
../../gcc/gcc/cp/pt.c:11052
0x99e07d complete_type(tree_node*)
../../gcc/gcc/cp/typeck.c:136
0x956130 do_type_instantiation(tree_node*, tree_node*, int)
../../gcc/gcc/cp/pt.c:22733
0x9095cf cp_parser_explicit_instantiation
../../gcc/gcc/cp/parser.c:16549
0x90fff1 cp_parser_declaration
../../gcc/gcc/cp/parser.c:12730
0x910341 cp_parser_declaration_seq_opt
../../gcc/gcc/cp/parser.c:12654
0x910634 cp_parser_translation_unit
../../gcc/gcc/cp/parser.c:4561
0x910634 c_parse_file()
../../gcc/gcc/cp/parser.c:38993
0xa0f096 c_common_parse_file()
../../gcc/gcc/c-family/c-opts.c:1132
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
$ g++ --version
g++ (GCC) 8.0.1 20180302 (experimental)
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ g++-7 main.cpp
main.cpp:9:21: internal compiler error: in retrieve_specialization, at
cp/pt.c:1185
class Outer< _T_ >::Inner< _T_ >{};
^~~~~~~~~~~~
0x5d2616 retrieve_specialization
../../gcc/gcc/cp/pt.c:1182
0x5e75e0 tsubst_decl
../../gcc/gcc/cp/pt.c:12190
0x5daa0f tsubst(tree_node*, tree_node*, int, tree_node*)
../../gcc/gcc/cp/pt.c:13432
0x5dfcaa most_specialized_partial_spec
../../gcc/gcc/cp/pt.c:21952
0x5f2ceb instantiate_class_template_1
../../gcc/gcc/cp/pt.c:10330
0x5f2ceb instantiate_class_template(tree_node*)
../../gcc/gcc/cp/pt.c:10898
0x656c35 complete_type(tree_node*)
../../gcc/gcc/cp/typeck.c:133
0x5f459b do_type_instantiation(tree_node*, tree_node*, int)
../../gcc/gcc/cp/pt.c:22229
0x64adbf cp_parser_explicit_instantiation
../../gcc/gcc/cp/parser.c:16229
0x62bb71 cp_parser_declaration
../../gcc/gcc/cp/parser.c:12464
0x6518cb cp_parser_declaration_seq_opt
../../gcc/gcc/cp/parser.c:12388
0x651bb2 cp_parser_translation_unit
../../gcc/gcc/cp/parser.c:4368
0x651bb2 c_parse_file()
../../gcc/gcc/cp/parser.c:38454
0x7225a3 c_common_parse_file()
../../gcc/gcc/c-family/c-opts.c:1107
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
$ g++-7 --version
g++-7 (GCC) 7.3.1 20180226
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ g++-6 main.cpp
main.cpp:9:21: internal compiler error: in retrieve_specialization, at
cp/pt.c:1183
class Outer< _T_ >::Inner< _T_ >{};
^~~~~~~~~~~~
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-6/README.Bugs> for instructions.
$ g++-6 --version
g++-6 (Ubuntu/Linaro 6.3.0-18ubuntu2~16.04) 6.3.0 20170519
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ g++-5 main.cpp
main.cpp:9:21: internal compiler error: in retrieve_specialization, at
cp/pt.c:1061
class Outer< _T_ >::Inner< _T_ >{};
^
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-5/README.Bugs> for instructions.
$ g++-5 --version
g++-5 (Ubuntu 5.4.1-2ubuntu1~16.04) 5.4.1 20160904
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.