[Bug c/60439] No warning for case overflow in switch statement.
chengniansun at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Mar 13 18:34:00 GMT 2014
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60439
--- Comment #3 from Chengnian Sun <chengniansun at gmail dot com> ---
(In reply to Marek Polacek from comment #2)
> Right. So I think there's nothing much to do. Please reopen if you
> strongly disagree.
Hi Marek,
>From the perspective of type system, I think no warning is fine. But from the
viewpoint of practice, IMHO this should be an overlooked case, as at runtime
there is indeed overflow.
The reason that I filed this report is not only that Clang emits a warning on
this issue (shown as below), but also that Gcc is able to handle the value
range of expressions (if I under the report PR60036 correctly).
-------------------------------------------------------------------
$: clang-trunk -Wswitch s.c -c
s.c:3:8: warning: overflow converting case value to switch condition type
(111111 to 7) [-Wswitch]
case 111111: return 1; /*warning here*/
^
s.c:8:3: warning: switch condition has boolean value
switch(c && d) {
^ ~~~~~~
More information about the Gcc-bugs
mailing list