This is the mail archive of the gcc-bugs@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]
Other format: [Raw text]

[Bug c/50922] infinite loop when optimized


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50922

--- Comment #2 from Mikael Pettersson <mikpe at it dot uu.se> 2011-10-30 17:03:10 UTC ---
(In reply to comment #0)
> int main(void)
> {
>  long x=0;
>  unsigned long c;
>  for(c=0;c<2147483648UL;c++)
>    {
>       lcdSendData(x++);
>     }

You're causing a signed overflow in the "x++" expression.  Try making x
"unsigned long" instead.  Or pass "-fwrapv" to gcc.


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