https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123592
Bug ID: 123592
Summary: [13/14/15/16 Regression] ICE in tsubst_expr, at
cp/pt.cc:22369 since 12.1 with checking
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/W5741dv7j
The following c++ code crash gcc trunk.
And goes back to 12.1 with checking.
If comment `TempUnion t = {.a = static_cast<int>(args)};`, only goes back to
12.3 withc checking.
Code:
```cpp
template <class T> void f(T) {
int i = 0;
auto g = [&](auto &&...args) {
struct TempUnion {
int a;
int b[i];
};
// Comment this line, only goes back to 12.3
TempUnion t = {.a = static_cast<int>(args)};
}();
};
int main() {
f(0.0f);
return 0;
}
```
Stack dump:
```
<source>: In instantiation of 'struct f<float>(float)::<lambda(auto:1&&
...)>::TempUnion':
required from 'f<float>(float)::<lambda(auto:1&& ...)> [with auto:1 = {}]'
<source>:9:5:
9 | };
| ^
required from 'void f(T) [with T = float]'
<source>:12:4:
5 | auto g = [&](auto &&...args) {
| ~~~~~~~~~~~~~~~~~~~~~
6 | struct TempUnion {
| ~~~~~~~~~~~~~~~~~~
7 | int a;
| ~~~~~~
8 | int b[i];
| ~~~~~~~~~
9 | };
| ~~
10 |
|
11 | // TempUnion t = {.a = static_cast<int>(args)};
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12 | }();
| ~^~
required from here
<source>:16:4:
16 | f(0.0f);
| ~^~~~~~
<source>:8:13: internal compiler error: in tsubst_expr, at cp/pt.cc:22369
8 | int b[i];
| ^
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
0xb168d0 fancy_abort(char const*, int, char const*)
???:0
0xd8f5d7 tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0xd8f672 tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0xd90012 tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0xdc1b11 instantiate_class_template(tree_node*)
???:0
0xdb9b6d instantiate_decl(tree_node*, bool, bool)
???:0
0xc2c523 maybe_instantiate_decl(tree_node*)
???:0
0xc2e337 mark_used(tree_node*, int)
???:0
0xb53c13 build_op_call(tree_node*, vec<tree_node*, va_gc, vl_embed>**, int)
???:0
0xddedf5 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
???:0
0xdb9b6d instantiate_decl(tree_node*, bool, bool)
???:0
0xdc357a instantiate_pending_templates(int)
???:0
0xc328a8 c_parse_final_cleanups()
???:0
0xec9428 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
```