https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123359
Bug ID: 123359
Summary: ICE: tree check: accessed elt 1 of ‘tree_vec’ with 0
elts in expand_template_argument_pack, at cp/pt.cc
when using co_await in a coroutine with invalid
multidimensional array parameter
Product: gcc
Version: 15.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: 522024330006 at smail dot nju.edu.cn
Target Milestone: ---
Reproducer: https://godbolt.org/z/7ceW3aTco
The compiler crashes when a coroutine function contains an invalid
multidimensional array declaration in its parameter list (e.g., int p[2][]).
While the compiler correctly identifies the syntax error for the array bounds,
it fails to recover and subsequently crashes during the instantiation of
coroutine-related logic when encountering co_await.
```C
#include <coroutine>
struct bug {};
std::suspend_never foo(int p[2][]) {
auto val = co_await bug();
}
```
Traceback:
```
<source>:7:28: error: declaration of 'p' as multidimensional array must have
bounds for all dimensions except the first
7 | std::suspend_never foo(int p[2][]) {
| ^
<source>: In function 'std::__n4861::suspend_never foo(...)':
<source>:8:29: internal compiler error: tree check: accessed elt 1 of
'tree_vec' with 0 elts in expand_template_argument_pack, at cp/pt.cc:4478
8 | auto val = co_await bug();
| ^
0x290fae8 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x29048ab internal_error(char const*, ...)
???:0
0xa1a391 tree_vec_elt_check_failed(int, int, char const*, int, char const*)
???:0
0xd9d54c coerce_template_parms(tree_node*, tree_node*, tree_node*, int, bool)
???:0
0xd893fd lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int)
???:0
0xbad517 finish_co_await_expr(unsigned long, tree_node*)
???:0
0xd52ed3 c_parse_file()
???:0
0xec4909 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.
```