This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/30020] New: missing limited range warning for a switch statement
- From: "sebor at roguewave dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 Nov 2006 19:43:08 -0000
- Subject: [Bug c/30020] New: missing limited range warning for a switch statement
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
I would expect gcc to issue the same or similar warning for both functions
below but the unreachable label in the switch statement isn't flagged even
with -Wall.
In addition, a new portability warning mode/option would be useful that would
point out cases like those below irrespective of -funsigned-char or other such
options.
$ cat t.c && gcc -Wall -c -funsigned-char t.c
int foo (char c)
{
switch (c) { case -1: return -1; };
return 0;
}
int bar (char c)
{
if (c == -1) return -1;
return 0;
}
t.c: In function `bar':
t.c:9: warning: comparison is always false due to limited range of data type
--
Summary: missing limited range warning for a switch statement
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: sebor at roguewave dot com
GCC build triplet: all
GCC host triplet: all
GCC target triplet: all
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30020