This is the mail archive of the gcc-bugs@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: [Bug c/35753] apparent integer math bug




Sent from my iPhone

On Mar 29, 2008, at 12:16, "regehr at cs dot utah dot edu" <gcc-bugzilla@gcc.gnu.org > 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




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