Sent from my iPhone

On Mar 29, 2008, at 12:16, "regehr at cs dot utah dot edu" <[EMAIL PROTECTED] > wrote:



------- Comment #3 from regehr at cs dot utah dot edu 2008-03-29 19:16 -------
Subject: Re:  apparent integer math bug

This multiplication overflows so the resulting behavior is undefined.

Right-- but always in the past it has been (or seemed) fine to assume
two's complement overflow behavior for signed arithmetic under gcc on
two's complement platforms.

I have seen the "strict overflow" options and those seem quite
reasonable. However, changing overflow behavior for multiply seems risky!

Is it still reasonable at least to rely on two's complement behavior for
signed addition and subtraction?

It never was reasonable to depend on this behaviour, just GCC got better at optimizing these cases. We have had the option -fwrapv since at least 3.3 so that people can use that option if the want full wrapping behavior with signed types. Note the C standard is over 18 years old now so I had hoped people would still not making the mistake of thinking signed interger being wrapping types.



Thanks,

John Regehr


--


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35753

Reply via email to