https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104765
Bug ID: 104765 Summary: Expression statement with a return in a lambda-parameter-default causes segfault when called in a different function Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: erich.keane at intel dot com Target Milestone: --- See this example: template<typename T> void call_lambda(T&& L) { L(); } int g() { auto x = [](char c = ({return 5;'c';})){}; call_lambda(x); return 0; } int main() { return g(); } :https://godbolt.org/z/T1cs766cM Output is: during RTL pass: expand <source>: In function 'void call_lambda(T&&) [with T = g()::<lambda(char)>&]': <source>:3:6: internal compiler error: Segmentation fault 3 | void call_lambda(T&& L) { | ^~~~~~~~~~~ 0x217ccb9 internal_error(char const*, ...) ???:0 0x1288575 coalesce_ssa_name(_var_map*) ???:0 0x120fadb rewrite_out_of_ssa(ssaexpand*) ???: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. Compiler returned: 1 This gets somewhat more interesting when the return value of 'call_lambda' is non-int: https://godbolt.org/z/rE619qbz3 <source>: In function 'long int call_lambda(T&&)': <source>:5:1: warning: no return statement in function returning non-void [-Wreturn-type] 5 | } | ^ <source>: In function 'long int call_lambda(T&&) [with T = g()::<lambda(char)>&]': <source>:3:6: error: invalid conversion in return statement 3 | long call_lambda(T&& L) { | ^~~~~~~~~~~ long int int return D.2194; <source>:3:6: internal compiler error: 'verify_gimple' failed 0x217ccb9 internal_error(char const*, ...) ???:0 0x1183efd verify_gimple_in_seq(gimple*) ???:0 0xdf13b1 gimplify_body(tree_node*, bool) ???:0 0xdf1677 gimplify_function_tree(tree_node*) ???:0 0xbf78f7 cgraph_node::analyze() ???:0 0xbfbe0d symbol_table::finalize_compilation_unit() ???: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. Compiler returned: 1 IMO, expression-statements in default-lambda parameters are... awkward and perhaps worth just prohibiting.