This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC] Detect most integer overflows.
- From: Florian Weimer <fweimer at redhat dot com>
- To: David Brown <david at westcontrol dot com>, Kai Tietz <ktietz70 at googlemail dot com>
- Cc: Andrew Haley <aph at redhat dot com>, OndÅej BÃlka <neleai at seznam dot cz>, Richard Biener <richard dot guenther at gmail dot com>, Hannes Frederic Sowa <hannes at stressinduktion dot org>, "gcc at gnu dot org" <gcc at gnu dot org>
- Date: Wed, 30 Oct 2013 15:06:30 +0100
- 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> <527111BC dot 3080105 at westcontrol dot com>
On 10/30/2013 03:03 PM, David Brown wrote:
Technically speaking, casting your signed values to unsigned and using
that to detect overflow will not necessarily work - I think it would be
"implementation defined". But almost all architectures use two's
compliment arithmetic, and it will work there.
We defined it to be bit-pattern-preserving as a GCC extension, anyway.
--
Florian Weimer / Red Hat Product Security Team