Joe Buck <[EMAIL PROTECTED]> 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