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

Arsen Arsenović <arsen at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic,
                   |                            |ice-on-invalid-code
             Status|UNCONFIRMED                 |NEW
            Summary|[coroutines] ICE when       |[coroutines] missing
                   |co_await used as default    |diagnostic and ICE when
                   |argument in function        |co_await used as default
                   |declaration                 |argument in function
                   |                            |declaration
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-07-15
                 CC|                            |arsen at gcc dot gnu.org

--- Comment #1 from Arsen Arsenović <arsen at gcc dot gnu.org> ---
testcase:

#include <coroutine>

struct Promise;

struct Handle : std::coroutine_handle<Promise> {
    using promise_type = Promise;
};

struct Promise {
    Handle get_return_object() noexcept {
        return {Handle::from_promise(*this)};
    }
    std::suspend_never initial_suspend() const noexcept { return {}; }
    std::suspend_never final_suspend() const noexcept { return {}; }
    void return_void() const noexcept {}
    void unhandled_exception() const noexcept {}
};

Handle Coro() {
    struct Awaiter : std::suspend_never {
        int await_resume() { return 0; }
    };

    void foo(int = co_await Awaiter{});
    co_return;
}

int main() {
    Coro();

    return 0;
}

(reposted in case the link expires - unmodified compared to #c0)

this code is invalid per https://eel.is/c++draft/expr.await#2 (as iains pointed
out).  seems that both we and clang fail to diagnose it.

Reply via email to