In an if-else combo, statements after the returns are not reported when running:
gcc -O3 -Wall -pedantic
- - -
static int broken()
i = 0;
i = 0;
2.95.3, provided by SuSE 7.2
Linux eumel 2.4.4-4GB #1 Wed May 16 00:37:55 GMT 2001 i686 unknown
gcc -O3 -Wall -pedantic -c broken.c -o broken.o
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?
2003-04-16 Roger Sayle <email@example.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.