https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122468
Bug ID: 122468
Summary: ICE: in build_new_method_call, at cp/call.cc:11896
Product: gcc
Version: 15.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: qingren2hxb at gmail dot com
Target Milestone: ---
Created attachment 62656
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62656&action=edit
bug report by using -freport-bug
============================================
# g++ -v
Using built-in specs.
COLLECT_GCC=/workspace/installation/bin/g++
COLLECT_LTO_WRAPPER=/workspace/installation/libexec/gcc/x86_64-pc-linux-gnu/15.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /workspace/gcc/configure --prefix=/workspace/installation
--enable-coverage --enable-checking --disable-multilib --disable-shared
--disable-bootstrap --enable-languages=c,c++
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 15.1.0 (GCC)
============================================
#include <coroutine>
struct bad_promise {
void return_void() {}
void return_value(int) {}
};
struct incomplete_coroutine_handle {};
template <>
struct std::coroutine_traits<int, int> {
using promise_type = bad_promise;
};
int coro_func(int x) {
co_await x;
if (x % 2 == 0)
co_return x * 2;
}
template<typename T>
using coro_t = T;
int main() {
auto handle = coro_t<std::coroutine_traits<int, int>>{};
}
============================================
# g++ -std=c++20 x.C -freport-bug
x.C: In function 'int coro_func(int)':
x.C:14:5: error: the coroutine promise type
'std::__n4861::coroutine_traits<int, int>::promise_type' {aka 'bad_promise'}
declares both 'return_value' and 'return_void'
14 | int coro_func(int x) {
| ^~~~~~~~~
x.C:4:10: note: 'return_void' declared here
4 | void return_void() {}
| ^~~~~~~~~~~
x.C:5:10: note: 'return_value' declared here
5 | void return_value(int) {}
| ^~~~~~~~~~~~
x.C:17:23: internal compiler error: in build_new_method_call, at
cp/call.cc:11896
17 | co_return x * 2;
| ^
0x5d4e2e6 internal_error(char const*, ...)
/workspace/gcc/gcc/diagnostic-global-context.cc:517
0x5cf3c1f fancy_abort(char const*, int, char const*)
/workspace/gcc/gcc/diagnostic.cc:1749
0xf120f2 build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, tree_node*, int, tree_node**, int)
/workspace/gcc/gcc/cp/call.cc:11896
0x101d699 coro_build_promise_expression
/workspace/gcc/gcc/cp/coroutines.cc:949
0x10222cd finish_co_return_stmt(unsigned long, tree_node*)
/workspace/gcc/gcc/cp/coroutines.cc:1715
0x13d2d1d cp_parser_jump_statement
/workspace/gcc/gcc/cp/parser.cc:15380
0x13c8daf cp_parser_statement
/workspace/gcc/gcc/cp/parser.cc:13131
0x13d38a4 cp_parser_implicitly_scoped_statement
/workspace/gcc/gcc/cp/parser.cc:15506
0x13ccfd4 cp_parser_selection_statement
/workspace/gcc/gcc/cp/parser.cc:14135
0x13c8cb6 cp_parser_statement
/workspace/gcc/gcc/cp/parser.cc:13114
0x13cbd30 cp_parser_statement_seq_opt
/workspace/gcc/gcc/cp/parser.cc:13859
0x13cb541 cp_parser_compound_statement
/workspace/gcc/gcc/cp/parser.cc:13706
0x13ff27d cp_parser_function_body
/workspace/gcc/gcc/cp/parser.cc:26708
0x13ff84e cp_parser_ctor_initializer_opt_and_function_body
/workspace/gcc/gcc/cp/parser.cc:26759
0x141b65e cp_parser_function_definition_after_declarator
/workspace/gcc/gcc/cp/parser.cc:33652
0x141b266 cp_parser_function_definition_from_specifiers_and_declarator
/workspace/gcc/gcc/cp/parser.cc:33567
0x13f4dad cp_parser_init_declarator
/workspace/gcc/gcc/cp/parser.cc:24009
0x13d7ba7 cp_parser_simple_declaration
/workspace/gcc/gcc/cp/parser.cc:16528
0x13d731e cp_parser_block_declaration
/workspace/gcc/gcc/cp/parser.cc:16347
0x13d6aa3 cp_parser_declaration
/workspace/gcc/gcc/cp/parser.cc:16201
Please submit a full bug report, with preprocessed source.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.