https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122857
Bug ID: 122857
Summary: coroutines: ICE tree check: expected record_type or
union_type or qual_union_type, have integer_type in
build_op_call, at cp/call.cc
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: ---
The details can be found here: https://godbolt.org/z/xW6E5vWqz
Program:
```c
#include <coroutine>
struct Task;
struct promise_type {
int return_value;
std::suspend_always initial_suspend() { return {}; }
std::suspend_never final_suspend() noexcept { return {}; }
void unhandled_exception() {}
};
struct Task {
using promise_type = ::promise_type;
};
Task foo(int* a) {
for (int i = 0; i < 5; ++i) {
a[i] = i * 2;
}
co_return 42; // Return via the promise's return value field
}
int main() {
int arr[10];
auto task = foo(arr);
}
```
The traceback:
26742.fuzz:25:15: internal compiler error: tree check: expected record_type or
union_type or qual_union_type, have integer_type in build_op_call, at
cp/call.cc:5447
25 | co_return 42; // Return via the promise's return value field
| ^~
0x5da1dc8 internal_error(char const*, ...)
/workspace/install/gcc/src/gcc/gcc/diagnostic-global-context.cc:517
0x2f49494 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
/workspace/install/gcc/src/gcc/gcc/tree.cc:9114
0xedbfd1 tree_check3(tree_node*, char const*, int, char const*, tree_code,
tree_code, tree_code)
/workspace/install/gcc/src/gcc/gcc/tree.h:3732
0xe94e90 build_op_call(tree_node*, vec<tree_node*, va_gc, vl_embed>**, int)
/workspace/install/gcc/src/gcc/gcc/cp/call.cc:5447
0xfd3bf8 coro_build_promise_expression
/workspace/install/gcc/src/gcc/gcc/cp/coroutines.cc:1040
0xfd8a37 finish_co_return_stmt(unsigned long, tree_node*)
/workspace/install/gcc/src/gcc/gcc/cp/coroutines.cc:1813
0x13938ec cp_parser_jump_statement
/workspace/install/gcc/src/gcc/gcc/cp/parser.cc:15382
0x13894c2 cp_parser_statement
/workspace/install/gcc/src/gcc/gcc/cp/parser.cc:13133
0x138c529 cp_parser_statement_seq_opt
/workspace/install/gcc/src/gcc/gcc/cp/parser.cc:13861
0x138bd1e cp_parser_compound_statement
/workspace/install/gcc/src/gcc/gcc/cp/parser.cc:13708
0x13c0ef3 cp_parser_function_body
/workspace/install/gcc/src/gcc/gcc/cp/parser.cc:26712
0x13c14d6 cp_parser_ctor_initializer_opt_and_function_body
/workspace/install/gcc/src/gcc/gcc/cp/parser.cc:26763
0x13de0cd cp_parser_function_definition_after_declarator
/workspace/install/gcc/src/gcc/gcc/cp/parser.cc:33711
0x13ddcae cp_parser_function_definition_from_specifiers_and_declarator
/workspace/install/gcc/src/gcc/gcc/cp/parser.cc:33626
0x13b63c5 cp_parser_init_declarator
/workspace/install/gcc/src/gcc/gcc/cp/parser.cc:24013
0x13989a6 cp_parser_simple_declaration
/workspace/install/gcc/src/gcc/gcc/cp/parser.cc:16532
0x13980ba cp_parser_block_declaration
/workspace/install/gcc/src/gcc/gcc/cp/parser.cc:16351
0x139782b cp_parser_declaration
/workspace/install/gcc/src/gcc/gcc/cp/parser.cc:16204
0x139799d cp_parser_toplevel_declaration
/workspace/install/gcc/src/gcc/gcc/cp/parser.cc:16225
0x1366c19 cp_parser_translation_unit
/workspace/install/gcc/src/gcc/gcc/cp/parser.cc:5469
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.
The gcc version I used is:
Using built-in specs.
COLLECT_GCC=/workspace/install/gcc/install_15.2.0/bin/gcc
COLLECT_LTO_WRAPPER=/workspace/install/gcc/install_15.2.0/libexec/gcc/x86_64-pc-linux-gnu/15.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /workspace/install/gcc/src/gcc/configure --enable-coverage
--enable-checking --disable-multilib --disable-shared --disable-bootstrap
--enable-languages=c,c++ --prefix=/workspace/install/gcc/install_15.2.0
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.2.0 (GCC)