https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122467
Bug ID: 122467
Summary: ICE: tree check: expected tree that contains 'decl
minimal' structure, have 'overload' in
coro_promise_type_found_p, at cp/coroutines.cc:759
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 62655
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62655&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 <vector>
#include <coroutine>
template <typename T>
struct task {
struct promise_type {
T value_;
std::suspend_never initial_suspend() { return {}; }
std::suspend_always final_suspend() noexcept { return {}; }
void unhandled_exception() {}
template<std::same_as<void> U = T>
requires std::is_void_v<U>
void return_void() {}
template<typename U = T>
requires (!std::is_void_v<U>)
void return_value(U&& value) {
value_ = std::forward<U>(value);
}
task get_return_object() { return {*this}; }
};
promise_type& p_;
explicit task(promise_type& p) : p_(p) {}
};
task<std::vector<int>> foo()
{
co_return std::vector<int>{1, 2, 3};
}
int main()
{
auto tsk = foo();
}
============================================
# g++ -std=c++20 x.C
x.C: In function 'task<std::vector<int> > foo()':
x.C:31:24: error: the coroutine promise type
'std::__n4861::__coroutine_traits_impl<task<std::vector<int> >,
void>::promise_type' {aka 'task<std::vector<int> >::promise_type'} declares
both 'return_value' and 'return_void'
31 | task<std::vector<int>> foo()
| ^~~
x.C:33:41: internal compiler error: tree check: expected tree that contains
'decl minimal' structure, have 'overload' in coro_promise_type_found_p, at
cp/coroutines.cc:759
33 | co_return std::vector<int>{1, 2, 3};
| ^
0x5d4e2e6 internal_error(char const*, ...)
/workspace/gcc/gcc/diagnostic-global-context.cc:517
0x2edc145 tree_contains_struct_check_failed(tree_node const*,
tree_node_structure_enum, char const*, int, char const*)
/workspace/gcc/gcc/tree.cc:9288
0xec31c7 contains_struct_check(tree_node*, tree_node_structure_enum, char
const*, int, char const*)
/workspace/gcc/gcc/tree.h:3838
0x101cd36 coro_promise_type_found_p
/workspace/gcc/gcc/cp/coroutines.cc:759
0x1021fed finish_co_return_stmt(unsigned long, tree_node*)
/workspace/gcc/gcc/cp/coroutines.cc:1673
0x13d2d1d cp_parser_jump_statement
/workspace/gcc/gcc/cp/parser.cc:15380
0x13c8daf cp_parser_statement
/workspace/gcc/gcc/cp/parser.cc:13131
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
0x13d6c21 cp_parser_toplevel_declaration
/workspace/gcc/gcc/cp/parser.cc:16222
0x13a6130 cp_parser_translation_unit
/workspace/gcc/gcc/cp/parser.cc:5469
0x1492cf4 c_parse_file()
/workspace/gcc/gcc/cp/parser.cc:53961
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.