This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/60439] New: No warning for case overflow in switch statement.
- From: "chengniansun at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 06 Mar 2014 07:06:25 +0000
- Subject: [Bug c/60439] New: No warning for case overflow in switch statement.
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60439
Bug ID: 60439
Summary: No warning for case overflow in switch statement.
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: chengniansun at gmail dot com
For the switch statement in the function f2, the controlling expression is
either 1 or 0, and the first "case 1111" exceeds the max value.
$: cat s.c
int f1(char c) {
switch(c) {
case 111111: return 1; /*warning here*/
default: return 0;
}
}
int f2(char c, char d) {
switch(c && d) {
case 1111: return 1; /*no warning here*/
default: return 0;
}
}
$: gcc-trunk -c s.c
s.c: In function âf1â:
s.c:3:3: warning: case label value exceeds maximum value for type
case 111111: return 1; /*warning here*/
^