This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Ada front-end depends on signed overflow
- From: Joe Buck <Joe dot Buck at synopsys dot COM>
- To: Andrew Pinski <pinskia at physics dot uc dot edu>
- Cc: Paul Schlie <schlie at comcast dot net>,Florian Weimer <fw at deneb dot enyo dot de>, GCC List <gcc at gcc dot gnu dot org>,bosch at gnat dot com
- Date: Fri, 3 Jun 2005 09:14:50 -0700
- Subject: Re: Ada front-end depends on signed overflow
- References: <BEC5F0DC.A5D5%schlie@comcast.net> <200506031543.j53FhWO9025589@earth.phy.uc.edu>
On Fri, Jun 03, 2005 at 11:43:32AM -0400, Andrew Pinski wrote:
> Everyone's who writes C/C++ should know that overflow of signed is undefined.
In practice, however, this issue is commonly ignored, because people code
in a hurry, then test the behavior of the executable code, and if on all
platforms tested there are overflows, but the overflows wrap and as a
result the expected thing happens, the problem will not be noticed.
I'm sure there are plenty of production codes that assume signed integer
overflow wraps, or at least make the weaker assumption that in
a = b + c + d;
where all variables are integers, if one of the intermediate terms
can't be represented in an integer, we still get the correct result
if the final result is representable in an integer.