https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93967
Bug ID: 93967 Summary: switch on exhaustive enum gives control reaches end of non-void function Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: gcc at cookiesoft dot de Target Milestone: --- ``` enum class A { X, Y, Z }; int foo(A a) { switch (a) { case A::X: return 1; case A::Y: return 2; case A::Z: return 3; } } ``` `g++ input.cpp` ``` <source>: In function 'int foo(A)': <source>:9:1: warning: control reaches end of non-void function [-Wreturn-type] 9 | } | ^ ``` The switch is exhaustive and so there is no way that the function reaches the code path after the switch. Clang does not emit a warning. This happens on every version of gcc. Godbolt: https://cpp.godbolt.org/z/Goii_K