This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/35753] apparent integer math bug
- From: "pinskia at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 Mar 2008 19:27:57 -0000
- Subject: [Bug c/35753] apparent integer math bug
- References: <bug-35753-12544@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from pinskia at gmail dot com 2008-03-29 19:27 -------
Subject: Re: 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
>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35753