This is the mail archive of the
mailing list for the GCC project.
Re: [Bug tree-optimization/19723] [4.0 Regression] A side effect is missed in 0 % a++.
On Tue, 1 Feb 2005, Paolo Bonzini wrote:
> > What I think we really want is to know whether or not the language
> > requires trapping on a DIV/MOD by zero. If so, then disable this class
> > of optimizations, otherwise we have a non-conformant program.
> May this fall into flag_unsafe_math_optimizations?
-funsafe-math-optimizations is documented to affect floating-point
operations, % is an integer-only operation.
-ftrapv is documented to be only for signed overflow on addition,
subtraction and multiplication, but it still seems a better match for an
option to guarantee runtime traps for all undefined behavior in integer
operations - including / and % by 0 and INT_MIN / -1. However we need to
allow for any requirements non-C languages might have for traps on 0 % 0
without wanting all the effects of -ftrapv.
Joseph S. Myers http://www.srcf.ucam.org/~jsm28/gcc/
email@example.com (personal mail)
firstname.lastname@example.org (CodeSourcery mail)
email@example.com (Bugzilla assignments and CCs)