This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/87951] GCC warns about reaching end of non-void function when all switch is completely handled
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 10 Dec 2018 10:10:24 +0000
- Subject: [Bug c++/87951] GCC warns about reaching end of non-void function when all switch is completely handled
- Auto-submitted: auto-generated
- References: <bug-87951-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87951
--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> ---
No.
They're not "less strict", but they have a fixed underlying type. For any
enumeration type with a fixed underlying type (whether "enum class" or just
"enum") the validvalues of the type are all the valid values of the underlying
type.
So:
enum E : unsigned char { e1, e2 };
enum class F : unsigned char { f1, f2 };
Both of these types can have any value from 0-255, so a switch statement that
only handles the e1/e2 or or f1/f2 is incorrect.
I wish people would just learn how enums work, it's not that complicated.