https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71440
Bug ID: 71440
Summary: ICE on invalid C++ code on x86_64-linux-gnu: in
instantiate_type, at cp/class.c:8247
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 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 also affect all earlier versions since at least 4.6.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 20160606 (experimental) [trunk revision 237117] (GCC)
$
$ g++-trunk -c small.cpp
small.cpp: In instantiation of ‘void C<T>::bar() [with T = int]’:
small.cpp:19:16: required from here
small.cpp:15:10: error: cannot call constructor ‘A::A’ directly
B < &A::A > b; // should be: B < &A::f > b;
^
small.cpp:15:17: internal compiler error: in instantiate_type, at
cp/class.c:8247
B < &A::A > b; // should be: B < &A::f > b;
^
0x73a7a0 instantiate_type(tree_node*, tree_node*, int)
../../gcc-source-trunk/gcc/cp/class.c:8244
0x6e526b convert_nontype_argument
../../gcc-source-trunk/gcc/cp/pt.c:6628
0x6ebcc3 convert_template_argument
../../gcc-source-trunk/gcc/cp/pt.c:7269
0x6f72eb coerce_template_parms
../../gcc-source-trunk/gcc/cp/pt.c:7730
0x6fa04a lookup_template_class_1
../../gcc-source-trunk/gcc/cp/pt.c:8313
0x6fa04a lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int, int)
../../gcc-source-trunk/gcc/cp/pt.c:8654
0x6fd88b tsubst_aggr_type
../../gcc-source-trunk/gcc/cp/pt.c:11437
0x6e6b77 tsubst(tree_node*, tree_node*, int, tree_node*)
../../gcc-source-trunk/gcc/cp/pt.c:12908
0x6ee2e7 tsubst_decl
../../gcc-source-trunk/gcc/cp/pt.c:12324
0x6e6f7e tsubst(tree_node*, tree_node*, int, tree_node*)
../../gcc-source-trunk/gcc/cp/pt.c:12829
0x6d4227 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../gcc-source-trunk/gcc/cp/pt.c:15174
0x6d4b30 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../gcc-source-trunk/gcc/cp/pt.c:15303
0x6d1535 instantiate_decl(tree_node*, int, bool)
../../gcc-source-trunk/gcc/cp/pt.c:22033
0x71e0f2 instantiate_pending_templates(int)
../../gcc-source-trunk/gcc/cp/pt.c:22152
0x7611d7 c_parse_final_cleanups()
../../gcc-source-trunk/gcc/cp/decl2.c:4600
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.
$
-------------------------------------------------
struct A
{
void f () {}
};
typedef void (A::*Ptr) ();
template < Ptr > struct B {};
template < class T >
struct C : public A
{
void bar ()
{
B < &A::A > b; // should be: B < &A::f > b;
}
};
template class C < int >;