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 <coroutine>
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:
<source>: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?