In an if-else combo, statements after the returns are not reported when running: gcc -O3 -Wall -pedantic - - - static int broken() { int i; if (0) { return(1); i = 0; } else { return(1); i = 0; } } Release: 2.95.3, provided by SuSE 7.2 Environment: Linux eumel 2.4.4-4GB #1 Wed May 16 00:37:55 GMT 2001 i686 unknown How-To-Repeat: gcc -O3 -Wall -pedantic -c broken.c -o broken.o
State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed with present 3.3CVS. You must add -Wunreachable-code, but it doesn't detect the problem here either.
It has been fixed on the mainline (20030524). Should this go into 3.3.1? Fixed by: 2003-04-16 Roger Sayle <roger@eyesopen.com> * c-semantics.c (find_reachable_label): New function to find a potentially reachable label in an expression. (expand_unreachable_if_stmt): Similar to expand_if_stmt but assumes the start of the IF_STMT is unreachable (dead) code. (expand_unreachable_stmt): Similar to expand_stmt but assumes the start of the statement list is unreachable (dead) code. (genrtl_if_stmt): If the controlling expression of the IF is constant, use expand_unreachable_stmt for the THEN or ELSE clause as appropriate. (genrtl_switch_stmt): Use expand_unreachable_stmt to expand the body of a SWITCH statement. (expand_stmt): The code immediately following a "return", "break", "continue" or "goto" is unreachable. * Makefile.in (c-semantics.o): Depend upon tree-inline.h.
Since this is fixed in 3.3.1 (20030526) and on the mainline (20030529), I am closing this as being fixed, you still have to use -Wunreachable-code.