http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58582
Bug ID: 58582 Summary: [c++11] ICE defining and instantiating deleted template function Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: reichelt at gcc dot gnu.org The following invalid code snippet (compiled with "-std=c++0x") triggers an ICE since GCC 4.4.0 (when deleted functions were introduced): ======================================== struct A { template<int> void foo() = delete; }; template<int> void A::foo() { int i; } template void A::foo<0>(); ======================================== bug.cc:6:20: error: redefinition of 'void A::foo()' template<int> void A::foo() { int i; } ^ bug.cc:3:22: note: 'void A::foo()' previously declared here template<int> void foo() = delete; ^ bug.cc: In instantiation of 'void A::foo() [with int <anonymous> = 0]': bug.cc:8:25: required from here bug.cc:6:36: internal compiler error: in add_stmt, at cp/semantics.c:386 template<int> void A::foo() { int i; } ^ 0x6ae530 add_stmt(tree_node*) ../../gcc/gcc/cp/semantics.c:386 0x5a43ac tsubst_expr ../../gcc/gcc/cp/pt.c:13289 0x5a1cdf instantiate_decl(tree_node*, int, bool) ../../gcc/gcc/cp/pt.c:19391 0x5de5ff instantiate_pending_templates(int) ../../gcc/gcc/cp/pt.c:19492 0x619766 cp_write_global_declarations() ../../gcc/gcc/cp/decl2.c:4060 Please submit a full bug report, [etc.] A slightly modified example (just leave out "int i;") crashes in a different place: ======================================== struct A { template<int> void foo() = delete; }; template<int> void A::foo() {} template void A::foo<0>(); ======================================== bug.cc:6:20: error: redefinition of 'void A::foo()' template<int> void A::foo() {} ^ bug.cc:3:22: note: 'void A::foo()' previously declared here template<int> void foo() = delete; ^ bug.cc: In instantiation of 'void A::foo() [with int <anonymous> = 0]': bug.cc:8:25: required from here bug.cc:6:30: internal compiler error: in finish_function, at cp/decl.c:13810 template<int> void A::foo() {} ^ 0x56ab15 finish_function(int) ../../gcc/gcc/cp/decl.c:13810 0x5a1d18 instantiate_decl(tree_node*, int, bool) ../../gcc/gcc/cp/pt.c:19402 0x5de5ff instantiate_pending_templates(int) ../../gcc/gcc/cp/pt.c:19492 0x619766 cp_write_global_declarations() ../../gcc/gcc/cp/decl2.c:4060 Please submit a full bug report, [etc.]