https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123671
Bug ID: 123671
Summary: [16 Regression] ICE (Segmentation fault) in
is_gimple_min_invariant when gimplifying
lambda-within-template-default-argument
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jirehguo at tju dot edu.cn
Target Milestone: ---
Compiler Explorer: https://godbolt.org/z/78vj7oToa
The following c++ code crash gcc trunk with -std=c++23 flag.
But gcc 12,13,14,15 with checking is fine.
Code:
```cpp
struct S { int i; };
struct bad {
template <auto L = [] {
struct { S s; } ct;
auto result = ct.s;
}>
static g() {
L();
}
};
int main() {
bad::g();
}
```
Stack dump:
```
<source>:10:10: error: ISO C++ forbids declaration of 'g' with no type
[-fpermissive]
10 | static g() {
| ^
<source>: In instantiation of 'static int bad::g() [with auto L = <lambda
closure object>main()::<lambda()>()]':
required from here
<source>:15:9:
15 | bad::g();
| ~~~~~~^~
<source>:12:3: warning: no return statement in function returning non-void
[-Wreturn-type]
12 | }
| ^
<source>: In lambda function:
<source>:8:36: internal compiler error: Segmentation fault
8 | auto result = ct.func;
| ~~~^~~~
0x2950a78 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x294583b internal_error(char const*, ...)
???:0
0x114f894 is_gimple_min_invariant(tree_node const*)
???:0
0x11eb542 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0x11ed5df gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0x12000f3 gimplify_arg(tree_node**, gimple**, unsigned long, bool)
???:0
0x11ec938 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0x11ec987 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0x11ef52a gimplify_stmt(tree_node**, gimple**)
???:0
0x11ec2db gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0x11ef52a gimplify_stmt(tree_node**, gimple**)
???:0
0x11ec7b0 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0x11ef52a gimplify_stmt(tree_node**, gimple**)
???:0
0x11ec7b0 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0x12109d6 gimplify_body(tree_node*, bool)
???:0
0x1210e9c gimplify_function_tree(tree_node*)
???:0
0xfc6c97 cgraph_node::analyze()
???:0
0xfca156 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
```