https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118319
Bug ID: 118319 Summary: ICE Segmentation fault in friend declaration with default argument assigned to an empty lambda expression 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: --- Test input: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ template <int> struct S{ friend void foo (int a = []{}()); }; void foo(int a){}; int main(){ S<0> t; foo(); } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Compiler Output: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <source>:2:19: error: friend declaration of 'void foo(int)' specifies default arguments and isn't a definition [-Wtemplate-body] 2 | friend void foo (int a = []{}()); | ^~~ <source>: In instantiation of 'struct S<0>': <source>:8:14: required from here 8 | S<0> t; | ^ <source>:2:19: error: friend declaration of 'void foo(int)' specifies default arguments and isn't the only declaration [-fpermissive] 2 | friend void foo (int a = []{}()); | ^~~ <source>:5:6: note: previous declaration of 'void foo(int)' 5 | void foo(int a){}; | ^~~ <source>: In function 'int main()': <source>:9:12: internal compiler error: Segmentation fault 9 | foo(); | ~~~^~ 0x2938005 diagnostic_context::diagnostic_impl(rich_location*, diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag (*) [1], diagnostic_t) ???:0 0x294ee06 internal_error(char const*, ...) ???:0 0xae4424 set_flags_from_callee(tree_node*) ???:0 0x17e3b1c walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*)) ???:0 0xd8da22 break_out_target_exprs(tree_node*, bool) ???:0 0xaeac9c convert_default_arg(tree_node*, tree_node*, tree_node*, int, int) ???:0 0xb0100e build_new_function_call(tree_node*, vec<tree_node*, va_gc, vl_embed>**, int) ???:0 0xd65696 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool, bool, int) ???:0 0xce562a c_parse_file() ???:0 0xe44f99 c_common_parse_file() ???:0 Please submit a full bug report, with preprocessed source. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Note that the template instantiation of 'S<0> t' here before the calling of 'foo' is necessary here. See https://godbolt.org/z/jcrKesYTh