On Sat, Jan 18, 2025 at 2:12 PM Lee Brown via Gcc <gcc@gcc.gnu.org> wrote: > > 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.
See the discussion in the bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95505 . That is there is no bug in libstdc++ nor in GCC in theory. Any use of get_return_object_on_allocation_failure for the promise_type requires new to be included. Now there should be a note about a missing include of new but that is just a small diagnostic issue. Thanks, Andrew Pinski > > 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 ---------------------------- >