https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123685
Bug ID: 123685
Summary: [13/14/15/16 Regression] ICE (Segfault) in
dependent_local_decl_p with local function call inside
nested generic lambdas
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/3TnrM5oMx
The following c++ code crash gcc trunk.
Goes back to 12.1
Code:
```cpp
void bar() {
void f();
auto lambda = [](auto x) {
return [x](auto y) { f(); };
};
lambda(1)(2);
}
```
Stack dump:
```
<source>: In instantiation of 'bar()::<lambda(auto:1)> [with auto:1 = int]':
required from here
<source>:6:9:
6 | lambda(1)(2);
| ~~~~~~^~~
<source>:4:27: internal compiler error: Segmentation fault
4 | return [x](auto y) { f(); };
| ~^~
0x2950b58 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x294591b internal_error(char const*, ...)
???:0
0xce2824 dependent_local_decl_p(tree_node*)
???:0
0xe03537 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
???:0
0xd8f11e tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
???:0
0xdc7c7d instantiate_decl(tree_node*, bool, bool)
???:0
0xc36863 maybe_instantiate_decl(tree_node*)
???:0
0xc38827 mark_used(tree_node*, int)
???:0
0xb5c0f3 build_op_call(tree_node*, vec<tree_node*, va_gc, vl_embed>**, int)
???:0
0xe03525 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
???:0
0xd64c43 c_parse_file()
???:0
0xeeed69 c_common_parse_file()
???: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
```