https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116455
Bug ID: 116455 Summary: Should std::noop_coroutine() be constexpr? Product: gcc Version: 14.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: daidodo at gmail dot com Target Milestone: --- Currently, the signature of std::noop_coroutine() is without `constexpr`: ``` inline std::noop_coroutine_handle noop_coroutine() noexcept { return noop_coroutine_handle(); } ``` (https://github.com/daidodo/gcc/blob/master/libstdc%2B%2B-v3/include/std/coroutine#L317) There is no way to define a `constexpr noop_coroutine_handle`: ``` constexpr std::noop_coroutine_handle noop = std::noop_coroutine(); // error ``` Is that intentional or something missing? Actually, `std::noop_coroutine_handle` has a default (constexpr) ctor. And both `std::coroutine_handle<void>` and `std::coroutine_handle<Promise>` have `constexpr` ctors and `from_address` (except that `from_promise` is non-constexpr). It seems unreasonable that we can define constexpr coroutine_handle's for `void` and all promises but not noop_coroutine_handle. I tested locally and it's just a keyword away for the following to work: ``` inline constexpr std::noop_coroutine_handle noop_coroutine() noexcept { return noop_coroutine_handle(); } // Now users can define constexpr noop_coroutine_handle. constexpr std::noop_coroutine_handle noop = std::noop_coroutine(); ``` Regards, Zhao