https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122883

            Bug ID: 122883
           Summary: ICE: tree check: expected tree that contains 'decl
                    minimal' structure, have 'overload' in
                    coro_promise_type_found_p, at cp/coroutines.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 code and results are as follows: https://godbolt.org/z/faqxbn58s

Program:
```c
#include <stdio.h>
#include <coroutine>
#include <string>

// Define a struct with exception-throwing destructor
struct Foo {
    ~Foo() noexcept(false) { throw 42; }
};

class CoroType final {
public:
    struct promise_type {
        std::suspend_never initial_suspend() { return {}; }
        std::suspend_always final_suspend()  noexcept { return {}; }

        void unhandled_exception() {}

        template<std::same_as<void> R>
        void return_void();

        template<typename T>
            requires std::is_constructible_v<Foo, T&&>
                void return_value(T&& value) {};

        auto yield_value(bool value) {
            return std::suspend_always{};
        }

        CoroType get_return_object() {
            return CoroType{handle_t::from_promise(*this)};
        }
     };

    using handle_t = std::coroutine_handle<promise_type>;
    explicit CoroType(handle_t hnd) : coro(hnd) {}

private:
   handle_t coro;
};

CoroType my_coroutine_generator()
{
   while (true) co_yield true;
}

```

Part of the traceback:
cases/28370.fuzz:73:26: internal compiler error: tree check: expected tree that
contains 'decl minimal' structure, have 'overload' in
coro_promise_type_found_p, at cp/coroutines.cc:839
   73 |    while (true) co_yield true;
      |                          ^~~~
0x5da1dc8 internal_error(char const*, ...)
        /workspace/install/gcc/src/gcc/gcc/diagnostic-global-context.cc:517
0x2f49ffb tree_contains_struct_check_failed(tree_node const*,
tree_node_structure_enum, char const*, int, char const*)
        /workspace/install/gcc/src/gcc/gcc/tree.cc:9288
0xe725b3 contains_struct_check(tree_node*, tree_node_structure_enum, char
const*, int, char const*)
        /workspace/install/gcc/src/gcc/gcc/tree.h:3838
0xfd3159 coro_promise_type_found_p
        /workspace/install/gcc/src/gcc/gcc/cp/coroutines.cc:839
0xfd7c83 finish_co_yield_expr(unsigned long, tree_node*)
        /workspace/install/gcc/src/gcc/gcc/cp/coroutines.cc:1673
0x13d0cee cp_parser_yield_expression
        /workspace/install/gcc/src/gcc/gcc/cp/parser.cc:30340
0x137f0a7 cp_parser_assignment_expression
        /workspace/install/gcc/src/gcc/gcc/cp/parser.cc:11092
0x137fa66 cp_parser_expression
        /workspace/install/gcc/src/gcc/gcc/cp/parser.cc:11281
0x138b392 cp_parser_expression_statement
        /workspace/install/gcc/src/gcc/gcc/cp/parser.cc:13598
0x138a175 cp_parser_statement
        /workspace/install/gcc/src/gcc/gcc/cp/parser.cc:13342
0x139467d cp_parser_already_scoped_statement
        /workspace/install/gcc/src/gcc/gcc/cp/parser.cc:15543
0x13927fb cp_parser_iteration_statement
        /workspace/install/gcc/src/gcc/gcc/cp/parser.cc:15112
0x138944c cp_parser_statement
        /workspace/install/gcc/src/gcc/gcc/cp/parser.cc:13123
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
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)

Reply via email to