https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115319
Bug ID: 115319 Summary: ICE when mutating a captured parameter in an explicit-this lambda if a capture is not trivially copyable Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: blubban at gmail dot com Target Milestone: --- struct S { S() {} S(const S&) {} }; void a() { [i=0, x=S{}](this auto self) -> void { i++; }(); } -std=c++23 (optional, it throws a c++23-extensions warning and the same ICE without it) <source>: In lambda function: <source>:11:9: internal compiler error: in gimplify_compound_lval, at gimplify.cc:3576 11 | i++; | ^ 0x202ef4c internal_error(char const*, ...) ???:0 0x778915 fancy_abort(char const*, int, char const*) ???:0 0xc4c739 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ???:0 0xc55a00 gimplify_self_mod_expr(tree_node**, gimple**, gimple**, bool, tree_node*) ???:0 0xc4cf52 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ???:0 0xc4e8c4 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ???:0 0xc4ca8d gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ???:0 0xc4e8ae gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ???:0 0xc50e8e gimplify_body(tree_node*, bool) ???:0 0xc51250 gimplify_function_tree(tree_node*) ???:0 0xaba647 cgraph_node::analyze() ???:0 0xabd9b1 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 Online reproducer: https://godbolt.org/z/Go6YdPTME It seems that the explicit this makes by-value captures mutable, so I think this is an ice-on-valid, but that is a pretty odd-sounding rule, so I'm not entirely sure. (one of my friends just discovered that posting GCC ICEs where I see them gets them reduced and reported. Said friend claims to encounter like billions of ICEs every day, so I may end up submitting a lot of ICEs and other gcc bugs in the near future. I'll make sure to reduce every testcase, validate that it is a bug, and try to find existing reports, of course)