https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123593
Bug ID: 123593
Summary: ICE: Segmentation fault in mark_use during
gimplification after lambda capture error
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/1KP81c3br
The following invalid c++ code crash gcc trunk.
And goes back to 12.1 with checking.
Code:
```cpp
int main() {
constexpr long shift_amount = ;
auto conv_expr = [&](long x) {
return x << shift_amount;
};
for (int l3;;) {
conv_expr(l3);
}
}
```
Stack dump:
```
<source>: In function 'int main()':
<source>:2:33: error: expected primary-expression before ';' token
2 | constexpr long shift_amount = ;
| ^
<source>: In lambda function:
<source>:4:14: error: 'shift_amount' is not captured
4 | return x << shift_amount;
| ~~^~~~~~~~~~~~~~~
<source>:2:18: note: 'constexpr const long int shift_amount' declared here
2 | constexpr long shift_amount = ;
| ^~~~~~~~~~~~
<source>:4:14: internal compiler error: Segmentation fault
4 | return x << shift_amount;
| ~~^~~~~~~~~~~~~~~
0x2929ea8 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x291ec6b internal_error(char const*, ...)
???:0
0xc494f3 mark_use(tree_node*, bool, bool, unsigned long, bool)
???:0
0xc48ed5 mark_use(tree_node*, bool, bool, unsigned long, bool)
???:0
0xbcfa0f ocp_convert(tree_node*, tree_node*, int, int, int)
???:0
0xead276 c_gimplify_expr(tree_node**, gimple**, gimple**)
???:0
0xbc473b cp_gimplify_expr(tree_node**, gimple**, gimple**)
???:0
0x11c401b gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0x11c4d9a gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0x11c865a gimplify_stmt(tree_node**, gimple**)
???:0
0x11c54bb gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0x11c865a gimplify_stmt(tree_node**, gimple**)
???:0
0x11c540b gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0x11c865a gimplify_stmt(tree_node**, gimple**)
???:0
0x11c58e0 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0x11e9b06 gimplify_body(tree_node*, bool)
???:0
0x11e9fcc gimplify_function_tree(tree_node*)
???:0
0xfa0bc7 cgraph_node::analyze()
???:0
0xfa4086 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
```