https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118202
Bug ID: 118202 Summary: ICE segmentation fault when instantiating a derived template class with default template argument and special overloaded ctor Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: wangbopku15 at gmail dot com Target Milestone: --- The following code triggers an ICE on the trunk: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ template <typename=int> class A; template <typename=int> class B: public A { B(); B(A a); }; void FPS() { B b; } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The default template argument values, the default ctor of `B` and the overloaded ctor with a parameter of base type `A` are essential factors to reproduce the bug. https://godbolt.org/z/b6n34sYEh ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <source>:4:19: error: expected class-name before '{' token [-Wtemplate-body] 4 | class B: public A { | ^ <source>:6:7: error: missing template argument list after 'A'; template placeholder not permitted in parameter [-Wtemplate-body] 6 | B(A a); | ^ | <> <source>:2:7: note: 'template<class> class A' declared here 2 | class A; | ^ <source>: In function 'void FPS()': <source>:12:5: internal compiler error: Segmentation fault 12 | B b; | ^ 0x2938075 diagnostic_context::diagnostic_impl(rich_location*, diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag (*) [1], diagnostic_t) ???:0 0x294ee76 internal_error(char const*, ...) ???:0 0xcf4a96 copy_guide_p(tree_node const*) ???:0 0xafb9e9 perform_dguide_overload_resolution(tree_node*, vec<tree_node*, va_gc, vl_embed> const*, int) ???:0 0xd0595f do_auto_deduction(tree_node*, tree_node*, tree_node*, int, auto_deduction_context, tree_node*, int, tree_node*) ???:0 0xbbee51 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int, cp_decomp*) ???:0 0xce5603 c_parse_file() ???:0 0xe450d9 c_common_parse_file() ???:0 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~