https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71748
Bug ID: 71748 Summary: ICE on valid (?) C++ template code invoking a base destructor: in build_base_path, at cp/class.c:304 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++ 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 also affects all versions since 4.7.x, but is accepted without any warnings by 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 20160703 (experimental) [trunk revision 237949] (GCC) $ $ g++-4.6 -c -Wall -Wextra -pedantic -std=c++0x small.cpp $ $ g++-trunk -c small.cpp small.cpp: In instantiation of ‘void foo() [with int <anonymous> = 0]’: small.cpp:19:14: required from here small.cpp:14:9: internal compiler error: in build_base_path, at cp/class.c:304 b->~A (); ~~~~~~^~ 0x7533e9 build_base_path(tree_code, tree_node*, tree_node*, int, int) ../../gcc-source-trunk/gcc/cp/class.c:304 0x66a1b1 build_over_call ../../gcc-source-trunk/gcc/cp/call.c:7489 0x6763d1 build_new_method_call_1 ../../gcc-source-trunk/gcc/cp/call.c:8521 0x6763d1 build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, tree_node*, int, tree_node**, int) ../../gcc-source-trunk/gcc/cp/call.c:8591 0x6e687f tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ../../gcc-source-trunk/gcc/cp/pt.c:16690 0x6d6cff tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc-source-trunk/gcc/cp/pt.c:15868 0x6d739a tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc-source-trunk/gcc/cp/pt.c:15180 0x6d66f3 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc-source-trunk/gcc/cp/pt.c:15166 0x6d8230 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc-source-trunk/gcc/cp/pt.c:15351 0x6d4c35 instantiate_decl(tree_node*, int, bool) ../../gcc-source-trunk/gcc/cp/pt.c:22095 0x721912 instantiate_pending_templates(int) ../../gcc-source-trunk/gcc/cp/pt.c:22214 0x764a45 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 { virtual ~A () {} }; struct B : public A { virtual ~B () {} }; template < int > void foo () { B *b = new B; b->~A (); } int main () { foo < 0 > (); return 0; }