When combining "-Wunreachable-code" with any optimizing above zero, "warning: will never be executed" under certain circumstances.
I've managed to create a small program that does show this bug, unless "nobug" is defined when compiling. $ gcc -v Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.2/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux Thread model: posix gcc version 3.4.2 20041017 (Red Hat 3.4.2-6.fc3) $ make cc -O3 -Wunreachable-code -save-temps test.c -o test test.c: In function `x': test.c:5: warning: will never be executed $ cat test.i # 1 "test.c" # 1 "<built-in>" # 1 "<command line>" # 1 "test.c" int x(int i,int *j) { *j = i; if (*j > 31) { printf("statement is executed\n"); } else { return 1; } return 0; } int main(int argc,char *argv[]) { int i,j,k; if (argc != 2) { printf("Usage: test <integer>\n"); return 1; } else { i=atoi(argv[1]); } k=x(i,&j); printf("j is now: %i\n",j); } $ ./test 123 statement is executed j is now: 123 $ ./test 1 j is now: 1 rm test mv test.i test.i.old $ cc -O3 -Wunreachable-code -save-temps test.c -o test -Dnobug $ diff test.i test.i.old 12c12 < printf("statement is not executed\n"); --- > In case it isn't clear: my test.c program contains: } else { #ifdef nobug printf("statement is not executed\n"); #endif return 1; } -- Summary: -O3 -Wunreachable-code failing Product: gcc Version: 3.4.2 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: alex at ergens dot op dot het dot net CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19354