This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Gcc-3.0 unroll bug
- To: hzoli at hzoli dot 2y dot net (Zoltan Hidvegi)
- Subject: Re: Gcc-3.0 unroll bug
- From: Joe Buck <jbuck at synopsys dot COM>
- Date: Fri, 20 Jul 2001 14:10:15 -0700 (PDT)
- Cc: edmar at motorola dot com, gcc at gcc dot gnu dot org
> > Consider the following for statement:
> > for (i = UINT_MAX - 1; i > 5; i++)
> > This statement should execute 2 times because, after that,
> > the i.v. will turn 0 and the condition (i > 5) will be false.
>
> Try the patch in
>
> http://gcc.gnu.org/ml/gcc-patches/2001-07/msg01080.html
>
> Also note that the behavior is undefined in the ANSI C++ standard
> (probably in C as well).
?? If i is unsigned, the behavior is defined; incrementing an unsigned
with value UINT_MAX-1 portably gives zero. The C and C++ standards
mandate that arithmetic on unsigned integers is modulo (UINT_MAX+1)
arithmetic.