This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/87951] GCC warns about reaching end of non-void function when all switch is completely handled


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]