public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/30020] New: missing limited range warning for a switch statement
@ 2006-11-29 19:43 sebor at roguewave dot com
2006-11-30 11:04 ` [Bug c/30020] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: sebor at roguewave dot com @ 2006-11-29 19:43 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c/30020] missing limited range warning for a switch statement
2006-11-29 19:43 [Bug c/30020] New: missing limited range warning for a switch statement sebor at roguewave dot com
@ 2006-11-30 11:04 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-11-30 11:04 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2006-11-30 11:04 -------
I think it is harder in this case as the char is promoted to int and then we
don't demote it until after the front-end is doing its parsing ...
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
GCC build triplet|all |
GCC host triplet|all |
GCC target triplet|all |
Keywords| |diagnostic
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30020
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-11-30 11:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-29 19:43 [Bug c/30020] New: missing limited range warning for a switch statement sebor at roguewave dot com
2006-11-30 11:04 ` [Bug c/30020] " pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).