This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/17544] [4.0 Regression] incorrect -Wunreachable-code warning for reachable code following a do statement
- From: "mmitchel at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Oct 2004 22:59:02 -0000
- Subject: [Bug c++/17544] [4.0 Regression] incorrect -Wunreachable-code warning for reachable code following a do statement
- References: <20040918001720.17544.sebor@roguewave.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From mmitchel at gcc dot gnu dot org 2004-10-09 22:59 -------
This is another example of why it is a mistake to use the optimizers to issue
warnings about unreachable code, uninitialized variables, etc.
There is no easy fix for the general case. The front end cannot avoid emitting
the return statement in all cases in which the back end might determine it is
unnecessary. We do not have an equivalent of DECL_ARTIFICIAL for statements or
expressions so there is no good way to flag the compiler-generated return for
the middle end.
The short-term fix is probably to special-case the situation where the last
statement in main is a return, either in the middle end or in the front end.
The longer-term fix is to move this warning out of the back end.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17544