[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
I can confirm this bug on the mainline (20030629) and in 3.3.1 (20030616). I also happens in 3.2.2 and 3.2.3 but does not in 3.0.4 (2.95.3 does not have the option), so this is a regression. Note this only happens with -march=i386 (with -march=i686 the warning does not happen).
*** Bug 11445 has been marked as a duplicate of this bug. ***
Subject: Bug 11370 CVSROOT: /cvs/gcc Module name: gcc Changes by: sayle@gcc.gnu.org 2003-07-09 01:17:28 Modified files: gcc : ChangeLog calls.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.dg: Wunreachable-6.c Wunreachable-7.c Log message: PR c/11370 * calls.c (emit_call_1): Don't bother popping the arguments off of the stack after a noreturn function call; The adjustment is dead. (expand_call): Likewise. * gcc.dg/Wunreachable-6.c: New testcase. * gcc.dg/Wunreachable-7.c: New testcase. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.412&r2=2.413 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/calls.c.diff?cvsroot=gcc&r1=1.284&r2=1.285 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2852&r2=1.2853 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/Wunreachable-6.c.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/Wunreachable-7.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
Roger, does this bug still need fixing somewhere or should it be closed?
This is a 3.3 regression only now. It has been fixed on the mainline.
Postponed until GCC 3.3.2.
Subject: Bug 11370 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: sayle@gcc.gnu.org 2003-08-09 03:50:05 Modified files: gcc : ChangeLog calls.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.dg: Wunreachable-6.c Wunreachable-7.c Log message: PR c/11370 * calls.c (emit_call_1): Don't bother popping the arguments off of the stack after a noreturn function call; The adjustment is dead. (expand_call): Likewise. * gcc.dg/Wunreachable-6.c: New testcase. * gcc.dg/Wunreachable-7.c: New testcase. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.699&r2=1.16114.2.700 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/calls.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.244.2.9&r2=1.244.2.10 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.249&r2=1.2261.2.250 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/Wunreachable-6.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.10.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/Wunreachable-7.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.10.1
Fixed for 3.3.2.