http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57138
Bug #: 57138
Summary: ICE in instantiate_class_template with variadic
templates, using declarations, save-temps and
precompiled header
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: [email protected]
ReportedBy: [email protected]
Created attachment 29990
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29990
Failing test case - test.cpp
Getting a segmentation fault in some variadic template code. The bug seems very
sensitive to small changes in input (e.g. removing a std::cout line causes the
compile to succeed, or give a compile error without ICE). Managed to reduce it
to a small test case, but removing further code (even unused code) causes the
issue to go away, as does removing the (empty) precompiled header, or the
-save-temps in the command line below.
Command lines:
g++ -Winvalid-pch -std=gnu++11 -I.. test.hpp -o test.hpp.gch
g++ -Winvalid-pch -std=gnu++11 -I.. -save-temps -c test.cpp
GCC Version:
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --enable-languages=c,c++ --disable-checking
--disable-multilib --disable-multiarch --disable-nls --enable-lto
--enable-libstdcxx-time
Thread model: posix
gcc version 4.8.0 (GCC)
Also tested with 4.7.2, which produces the same error for this test case,
though is also sensitive to input and sometimes succeeds where 4.8 fails, or
vice versa.
Output from 4.8.0:
g++ -Winvalid-pch -std=gnu++11 -I.. -save-temps -c test.cpp
test.cpp: In instantiation of 'struct specify_some<C>':
test.cpp:46:20: required from here
test.cpp:29:55: internal compiler error: Segmentation fault
using type = Type<specified_args..., more_args...>;
^
0x86943f crash_signal
../../gcc/toplev.c:332
0x508fd8 tsubst(tree_node*, tree_node*, int, tree_node*)
../../gcc/cp/pt.c:11227
0x50c992 tsubst_template_args
../../gcc/cp/pt.c:9607
0x5091b8 tsubst(tree_node*, tree_node*, int, tree_node*)
../../gcc/cp/pt.c:11465
0x50952d tsubst(tree_node*, tree_node*, int, tree_node*)
../../gcc/cp/pt.c:11107
0x50eb00 lookup_template_class_1
../../gcc/cp/pt.c:7363
0x50eb00 lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int, int)
../../gcc/cp/pt.c:7562
0x5090af tsubst(tree_node*, tree_node*, int, tree_node*)
../../gcc/cp/pt.c:11337
0x50816e tsubst_decl
../../gcc/cp/pt.c:10625
0x509694 tsubst(tree_node*, tree_node*, int, tree_node*)
../../gcc/cp/pt.c:11081
0x507f73 tsubst_decl
../../gcc/cp/pt.c:10037
0x509694 tsubst(tree_node*, tree_node*, int, tree_node*)
../../gcc/cp/pt.c:11081
0x516817 instantiate_class_template_1
../../gcc/cp/pt.c:8818
0x516817 instantiate_class_template(tree_node*)
../../gcc/cp/pt.c:9054
0x56241d complete_type(tree_node*)
../../gcc/cp/typeck.c:131
0x5624bd complete_type_or_maybe_complain(tree_node*, tree_node*, int)
../../gcc/cp/typeck.c:143
0x4ec949 xref_basetypes(tree_node*, tree_node*)
../../gcc/cp/decl.c:12105
0x543ef1 cp_parser_class_head
../../gcc/cp/parser.c:18895
0x543ef1 cp_parser_class_specifier_1
../../gcc/cp/parser.c:18194
0x543ef1 cp_parser_class_specifier
../../gcc/cp/parser.c:18463
And from 4.7:
test.cpp: In instantiation of 'struct specify_some<C>':
test.cpp:46:20: required from here
test.cpp:44:33: internal compiler error: Segmentation fault
Please excuse the slightly horrific use of variadic templates...