------- 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