> Robert Dewar wrote:
> ...
> I think it is a bad idea for the optimization levels to deal with
> anything other than optimization. -fwrapv is not about optimization,
> it is about changing the language semantics.
> 
> So this proposal would be tantamount to implementing a different
> language at -O1 and -O2, and having -O2 change the formal
> semantic interpretation of the program. That seems a very
> bad idea to me.
> ...

Yes, it would be laudable for GCC to adopt the principle that whatever
language semantics are chosen in absents of optimization should be
preserved through -O2 by default; although may be explicitly overridden
as may be desired by the user.

Further as this may be target specific, for target machine implementations
which inherently support trapping on overflow (or null pointer dereference);
GCC may correspondingly then enable through -O2 optimizations presuming the
same; but by principle not otherwise for targets for which GCC does not
factually support these semantics.


Reply via email to