https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93674

--- Comment #2 from Gábor Buella <gbuella at gmail dot com> ---
(In reply to Andrew Pinski from comment #1)
> -fstrict-enums
> Allow the compiler to optimize using the assumption that a value of
> enumerated type can only be one of the values of the enumeration (as defined
> in the C++ standard; basically, a value that can be represented in the
> minimum number of bits needed to represent all the enumerators). This
> assumption may not be valid if the program uses a cast to convert an
> arbitrary integer value to the enumerated type.
> 
> ---- CUT ---
> I assume that means since there is no negative numbers in the enum, that
> means you might get undefined behavior if j is negative ...

Look at the code, j is never negative when the cast is applied.
You can easily verify it by printing the e.g. values.

Reply via email to