https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123532
Bug ID: 123532
Summary: [16 Regression] ICE in insert_capture_proxy, at
cp/lambda.cc:343
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/rEczW9eqq
The following c++ code crash gcc trunk. But gcc 13, 14, 15 is fine.
Code:
```cpp
int main() {
int i = 1;
int args[i] = {1, 2};
auto lambda = [&](auto... values) {
return [&]() {
func(args[0], args[1]);
}
};
}
```
Stack dump:
```
<source>: In lambda function:
<source>:6:12: sorry, unimplemented: capture of variably-modified type 'int
[(__closure->main()::<lambda(auto:1 ...)>::<args
capture>.main()::<lambda(auto:1 ...)>::<lambda()>::<unnamed struct>::max + 1)]'
that is not an N3639 array of runtime bound
6 | func(args[0], args[1]);
| ^~~~
<source>:6:21: sorry, unimplemented: capture of variably-modified type 'int
[(__closure->main()::<lambda(auto:1 ...)>::<args
capture>.main()::<lambda(auto:1 ...)>::<lambda()>::<unnamed struct>::max + 1)]'
that is not an N3639 array of runtime bound
6 | func(args[0], args[1]);
| ^~~~
<source>:6:7: error: there are no arguments to 'func' that depend on a template
parameter, so a declaration of 'func' must be available [-Wtemplate-body]
6 | func(args[0], args[1]);
| ^~~~
<source>:6:7: note: (if you use '-fpermissive', G++ will accept your code, but
allowing the use of an undeclared name is deprecated)
<source>: In lambda function:
<source>:7:5: internal compiler error: in insert_capture_proxy, at
cp/lambda.cc:343
7 | }
| ^
0x2924d48 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x2919b0b internal_error(char const*, ...)
???:0
0xb16bf2 fancy_abort(char const*, int, char const*)
???:0
0xc5c1ae insert_pending_capture_proxies()
???:0
0xd573b3 c_parse_file()
???:0
0xec8de9 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
```