Just to be clear,   the appended 17 lines of very simple code breaks gcc
on every platform where <coroutine> header does not have <new> in its
include hierarchy....which I assume to be every platform.

1) place code below in main.cpp

2) g++ -std=c++20 main.cpp

and you get

main.cxx: In function 'my_co do_co()':
main.cxx:16:7: error:
'my_co::promise_type::get_return_object_on_allocation_failure()' is
provided by 'std::__n4861::__coroutine_traits_impl<my_co,
void>::promise_type' {aka 'my_co::promise_type'} but *'std::nothrow'
cannot be found*
   16 | my_co do_co() { co_return; }
      |       ^~~~~


Here's the code:

// begin code --------------------------------

#include <coroutine>

struct my_co {
    struct promise_type {
        static    my_co get_return_object_on_allocation_failure() {
return my_co(); }
                my_co get_return_object()     { return my_co(); }

        std::suspend_always initial_suspend() noexcept     { return {}; }
        std::suspend_always final_suspend() noexcept     { return {}; }
        void                 return_void()                 {}
        void                 unhandled_exception()         {}
    };
};

my_co do_co() { co_return; }

int main()
{
    do_co();
    return 0;
}

// end code ----------------------------

Reply via email to