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: Where does the C standard describe overflow of signed integers?


>>>>> "Matthew" == Matthew Woodcraft <mattheww@chiark.greenend.org.uk> writes:

 Matthew> Paul Schlie wrote:
 >> As optimization seems to be a non-argument, as by analogy all
 >> optimizations which are available for unsigned arithmetic are
 >> correspondingly available for signed integer operations; as any
 >> signed value may then be thought of as being unsigned for the
 >> purposes of computation and/or comparison.

 Matthew> What about optimising x*2/2 to x?

If that doesn't overflow then it's valid, and if overflow is undefined
it's valid in that case, too.  :-)

Of course this would be an example where overflow isn't treated as 2s
complement wrap...

     paul


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