This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: false 'noreturn' function does return warnings


Joe Buck <Joe.Buck@synopsys.COM> writes:

> On Tue, Feb 06, 2007 at 04:14:30PM -0800, Ian Lance Taylor wrote:
> > I also think it would be good to have one option affecting it: turn
> > __builtin_unreachable() into an abort(), or turn it into a "cannot be
> > reached" marker.  I think the former should be the default at -O0, the
> > latter at -O1 and above.
> > 
> > Note that a "cannot be reached" marker permits further optimization to
> > delete code which leads up to it.  Actually implementing that further
> > optimization may call for adding appropriate warnings, probably
> > controlled by -Wunreachable-code.
> 
> Ouch.
> 
> In the case that motivated this discussion, the instruction that would
> immediately go before the __builtin_unreachable() is a trap instruction,
> but the compiler does not know that it traps.  It would be very bad
> if the compiler eliminated the trap, since it is the presence of the
> trap that keeps the function from returning.

Well, a trap instruction would presumably be volatile.  The compiler
would not eliminate a volatile instruction.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]