[Bug c++/109867] New: -Wswicht-default reports missing default in coroutine
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109867 Bug ID: 109867 Summary: -Wswicht-default reports missing default in coroutine Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: lukaslang.bugtracker at outlook dot com Target Milestone: --- Consider the following implementation of a simple coroutine (https://godbolt.org/z/rcevTd5f6): #include struct task { struct promise_type { std::suspend_always initial_suspend(); std::suspend_always final_suspend() noexcept; void unhandled_exception(); task get_return_object(); void return_value(int); }; }; int main() { auto t = []() -> task { co_return 2; }(); } Compiling this with -std=c++20 -Wswitch-default -Werror results in an error at the end of the coroutine body: :20:5: error: switch missing default case [-Werror=switch-default] 20 | }(); Since I can get neither clang nor msvc to complain, I assume this is a bug, or am I missing something? If this is indeed a bug, can I work around this without having to disable the warning?
[Bug c++/110171] New: [[nodiscard]] of await_resume ignored when discarding result of co_await expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110171 Bug ID: 110171 Summary: [[nodiscard]] of await_resume ignored when discarding result of co_await expression Product: gcc Version: 11.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: lukaslang.bugtracker at outlook dot com Target Milestone: --- (Note: The example & bug is very similar to this here: https://developercommunity.visualstudio.com/t/nodiscard-not-honored-by-co_await/1500944) It seems that discarding the `co_await`ed result of an awaitable with `[[nodiscard]]` `await_resume` doesn't lead to the expected warning ([Godbolt](https://godbolt.org/z/o47EdzMj8)): ``` #include struct must_check_result { bool await_ready() { return false; } void await_suspend(std::coroutine_handle<>) {} [[nodiscard]] bool await_resume() { return {}; } }; struct task {}; namespace std { template struct coroutine_traits { struct promise_type { task get_return_object() { return {}; } suspend_always initial_suspend() noexcept { return {}; } suspend_always final_suspend() noexcept { return {}; } void return_void() {} void unhandled_exception() {} }; }; } task example() { co_await must_check_result(); // no warning even though await_ready is marked [[nodiscard]] must_check_result().await_resume(); } ```