[Bug c++/42810] Enumeration with sequential values has its for-loop exit condition optimized out.
jakub at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Tue Jan 19 23:56:00 GMT 2010
------- Comment #7 from jakub at gcc dot gnu dot org 2010-01-19 23:56 -------
This testcase also uses out of range enum value, so has undefined behavior as
well. For ENUM_VALUE_LAST which is a power of 2 minus 1 the for loop condition
still lets the body to be executed, then id = static_cast<ENUM_VALUE>(id+1)
i.e. id = static_cast<ENUM_VALUE>(ENUM_VALUE_LAST+1) is the out of range value.
The compiler can assume that no enum value is larger than ENUM_VALUE_LAST if it
is a power of 2 minus 1 (i.e. the largest value of the underlying type).
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42810
More information about the Gcc-bugs
mailing list