[Bug c/11370] New: -Wunreachable-code gives false complaints
debian-gcc at lists dot debian dot org
gcc-bugzilla@gcc.gnu.org
Sun Jun 29 10:57:00 GMT 2003
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11370
Summary: -Wunreachable-code gives false complaints
Product: gcc
Version: 3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: debian-gcc at lists dot debian dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i386-linux
GCC host triplet: i386-linux
GCC target triplet: i386-linux
[forwarded from http://bugs.debian.org/196600]
rechecked with HEAD.
Gcc complains that a declaration "will never be executed" for a
code path that executes, as shown below.
If I:
. remove the exit line
. change "int ix;" to "int ix = 0;"
or
. move the declaration to line 2 or after line 3
the complaint go away.
$ cat -n test.c
#include <stdio.h>
int main(int argc, char *argv[]) { /* line 3 */
if (argc != 1) exit(1);
{
int ix; /* line 7 */
ix = printf("hello\n");
printf("%d\n", ix);
}
return 0;
}
$ gcc-3.3 -Wunreachable-code test.c; ./a.out
test.c: In function `main':
test.c:7: warning: will never be executed
hello
6
More information about the Gcc-bugs
mailing list