http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46806

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-12-05 
19:27:39 UTC ---
Hmm, I might have been too hasty declaring this invalid.

The comparisons are ok, with or without casts, I think the problem is this
line:
    Value = static_cast<TEValue>(Eight);

The optimiser thinks that because you do that cast, that implies that Eight
must be in the range [0,7] always, not just when you've checked that it is
actually in range.

Changing that line to this prevents the condition always being true:
    Value = static_cast<TEValue>(Eight%8);

The condition before that line should ensure that's not needed, because you've
already ensured the value is in range, so maybe there is a bug here, which is
hidden in 4.6 by -fstrict-enums being off by default.

I'm re-opening this again, could a front-end or middle-end maintainer comment
on whether this really is invalid?

Reply via email to