This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/11370] New: -Wunreachable-code gives false complaints
- From: "debian-gcc at lists dot debian dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 Jun 2003 10:57:52 -0000
- Subject: [Bug c/11370] New: -Wunreachable-code gives false complaints
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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