This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Gcc-3.0 unroll bug



> > 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.




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]