------- Comment #5 from tuttle at sandbox dot cz 2008-02-16 14:12 ------- I think we could generalize a bit: This in fact is not bound to if-statement or code reachability.
Tried the following with snapshot gcc-4.3-20080215 -Wextra -Wall -Wunreachable-code. #include <stdio.h> int main() { int var1 = (1 && 0); /* does not warn */ printf("var1 = %d\n", var1); /* outputs: var1 = 0 */ if ( 0 && 1 ) printf("FIRST\n"); /* warns ok: printf unreachable */ if ( 0 && (var1 == 10) ) printf("SECOND\n"); /* warns ok: printf unreachable */ if ( (var1 == 10) && (var1 == 20) ) printf("THIRD\n"); /* does not warn */ return 0; } 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. I just tried to provide an idea. With deep respect, Vlada Macek -- tuttle at sandbox dot cz changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|Missing a warning: if- |Missing a warning: |condition is inherently |inherently false expressions |blocking the if-body | Version|4.1.3 |4.3.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35188