This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/7322: Code to Compute Numeric Limits "runs away" when -O<any> used
- From: nathan at gcc dot gnu dot org
- To: gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, lprimak at hope dot nyc dot ny dot us, nobody at gcc dot gnu dot org
- Date: 16 Jul 2002 08:41:43 -0000
- Subject: Re: c++/7322: Code to Compute Numeric Limits "runs away" when -O<any> used
- Reply-to: nathan at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, lprimak at hope dot nyc dot ny dot us, nobody at gcc dot gnu dot org, gcc-gnats at gcc dot gnu dot org
Synopsis: Code to Compute Numeric Limits "runs away" when -O<any> used
State-Changed-From-To: open->closed
State-Changed-By: nathan
State-Changed-When: Tue Jul 16 01:41:42 2002
State-Changed-Why:
The code is ill formed.
There are tests such as
if (T (max + 1) > max)
where max & T are signed types. [5]/5 says that
if the result is not in the range if representable values,
the behaviour is undefined. gcc implements modulo arithmetic
for unsigned types, and undefined behaviour for signed types.
The optimized therefore knows that max + 1 must always
be greater than max.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7322