@cmuratori Warning for undefined behavior is pretty standard. Why not compare before casting?
-
-
Replying to @taradinoc
@taradinoc Because you may be doing it in an assertion. Ie., "assert that this enum is in range when I get it". That's extremely common.1 reply 0 retweets 0 likes -
Replying to @cmuratori
@taradinoc Now all of those would have to be casted to integer types first.1 reply 0 retweets 0 likes -
Replying to @cmuratori
@cmuratori The compiler can choose the size of the enum to match the values, so that comparison may not be meaningful.1 reply 0 retweets 0 likes -
Replying to @taradinoc
@taradinoc It _can_, but it _did not_. The largest value allowed for functioning of the software in this case was 64.1 reply 0 retweets 0 likes -
Replying to @cmuratori
@taradinoc So it warned on "enum < 64", even though it was not using some magical hardware 6-bit type for future operations.3 replies 0 retweets 0 likes -
Replying to @cmuratori
@cmuratori Such warnings tell you that your program may work unexpectedly on SOME conforming compiler, not necessarily the one you're using.1 reply 0 retweets 0 likes -
Replying to @taradinoc
@taradinoc No, it does not tell you that at all. There is no case where this comparison will result in unexpected behavior of the program.1 reply 0 retweets 0 likes -
Replying to @cmuratori
@taradinoc It's another in the long string of new "warnings" that often warn about things that are usually used _correctly_.1 reply 0 retweets 0 likes -
Replying to @cmuratori
@taradinoc Sure, someone _could_ use the comparison incorrectly, but someone could use _anything_ incorrectly.1 reply 0 retweets 0 likes
@taradinoc If that was the criteria, the compiler should be warning you about a + b because it "could overflow".
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.