This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC] Detect most integer overflows.
- From: Andrew Haley <aph at redhat dot com>
- To: David Brown <david at westcontrol dot com>
- Cc: OndÅej BÃlka <neleai at seznam dot cz>, Trevor Saunders <tsaunders at mozilla dot com>, gcc at gcc dot gnu dot org
- Date: Wed, 30 Oct 2013 15:56:00 +0000
- Subject: Re: [RFC] Detect most integer overflows.
- Authentication-results: sourceware.org; auth=none
- References: <20131026192912 dot GA25428 at domone dot podge> <20131026235014 dot GF18009 at order dot stressinduktion dot org> <CAFiYyc0+wTbE1FwwLscquWvoEtM6JQw4p5qhnhBmGtVCMkx9fQ at mail dot gmail dot com> <20131030083413 dot GA12183 at domone dot podge> <5270C63C dot 6030406 at redhat dot com> <CAEwic4a9O7a2S34NEzZ5iq2oef=5Agmr863Thj5=MsENa_nxGg at mail dot gmail dot com> <20131030144909 dot GA4555 at tsaunders-iceball dot corp dot tor1 dot mozilla dot com> <20131030145959 dot GA15771 at domone dot podge> <52712468 dot 3060308 at westcontrol dot com>
On 10/30/2013 03:23 PM, David Brown wrote:
> I believe that's only a minor reason for making signed overflows
> undefined behaviour. If it were a matter of implementation, I think it
> would have been made "implementation defined" rather than "undefined",
> so that two's complement machines could use wrapping while other systems
> (which are very rare now) could have other defined overflow behaviour.
>
> The main reason (again, this is my guess - I don't know what the C
> standards folk /actually/ thought) is that there is no obvious "correct"
> behaviour for signed overflow
A more important reason that having signed overflow undefined allows
a lot of powerful loop optimization algorithms.
Andrew.