------- Comment #11 from ian at airs dot com  2005-10-17 04:39 -------
For the record, this is the work-around in the C frontend:
    http://gcc.gnu.org/ml/gcc-patches/2005-01/msg01452.html
A corresponding patch in the C++ frontend would be more complicated, in order
to continue to emit the error "break statement not within loop or switch" when
required.

This class of bugs is a pain to work with at present.  The warning just follows
the CFG, which makes sense.  But code like
  case 1:
    return;
    break;
builds a CFG which has a return followed by a goto.  remove_useless_stmts is
currently not clever enough to remove code after a return, so the goto gets
incorporated into the CFG.  Note that we don't get the warning when optimizing;
we only get it with -O0.  And indeed when not optimizing the assembly code has
the code path which returns an uninitialized value, although of course it never
gets executed in practice.

Fixing this in the middle-end will require a version of remove_useless_stmts
which is clever enough to efficiently discard statements which follow a return
statement.  Andrew was working on that at one point; I don't recall what the
status is.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20681

Reply via email to