This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/53479] Control flow analysis reports warnings in switch over an enum class even if all possible values have their branches
- 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: Sun, 11 Sep 2016 15:11:13 +0000
- Subject: [Bug c++/53479] Control flow analysis reports warnings in switch over an enum class even if all possible values have their branches
- Auto-submitted: auto-generated
- References: <bug-53479-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53479
--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Eric Gallager from comment #6)
> This should probably depend on the -fstrict-enums flag, as that controls
> whether enums can have any value or just those values that are enumerated.
No, that's not what it does.
It tells the compiler the enum will only be one of the values of the
enumeration, which is not the same as the values corresponding to enumerators.
As I said in comment 3, the OP's type has the values of int, because it has an
underlying type of int.
Given enum E { E1 = 1, E3 = 3 } the values of the type are 0, 1, 2 and 3 and
-fstrict-enums tells the compiler it will never have a value outside that
range. It does **not** tell it that the type will never have the value 0 or 2.