------- Comment #6 from manu at gcc dot gnu dot org 2008-02-16 17:50 ------- > Please do not expect a compilable testcase from me. 1) I don't know whether > this is a bug, 2) have no experience in gcc testcases.
The above is a testcase. See http://gcc.gnu.org/bugs.html#report on how to make a good report. A more self-contained and complete testcase follows: extern void abort(void); void foo(int var2) { int var1 = 0; if (0 && 1) abort (); if (0 && var1 == 10) abort (); if (var1 == 10 && var1 == 20) abort (); if (var1 == 10) if (var1 == 20) abort (); if (var2 == 10 && var2 == 20) abort (); if (var2 == 10) if (var2 == 20) abort (); } The above gives with -Wunreachable-code -O0 /home/manuel/src/pr35188.c:8: warning: will never be executed /home/manuel/src/pr35188.c:11: warning: will never be executed And with -Wunreachable-code -O1 /home/manuel/src/pr35188.c: In function foo: /home/manuel/src/pr35188.c:8: warning: will never be executed /home/manuel/src/pr35188.c:11: warning: will never be executed /home/manuel/src/pr35188.c:14: warning: will never be executed /home/manuel/src/pr35188.c:21: warning: will never be executed Performing interprocedural optimizations <visibility> <early_local_cleanups> /home/manuel/src/pr35188.c:17: warning: will never be executed /home/manuel/src/pr35188.c:18: warning: will never be executed <inline> <static-var> <pure-const>Assembling functions: foo /home/manuel/src/pr35188.c: In function foo: /home/manuel/src/pr35188.c:25: warning: will never be executed So, it is jut that without optimizations enabled, GCC does not know that (var == 1 && var == 2) is always false and hence it does not consider the code unreachable. I am inclined to close this as WONTFIX. -- manu at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |manu at gcc dot gnu dot org Status|UNCONFIRMED |WAITING http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35188