[Bug c/56600] loop goes indefinite when non-loop integer variable overflows

jasonwucj at gmail dot com gcc-bugzilla@gcc.gnu.org
Sat Mar 16 11:44:00 GMT 2013


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

Chung-Ju Wu <jasonwucj at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jasonwucj at gmail dot com

--- Comment #3 from Chung-Ju Wu <jasonwucj at gmail dot com> 2013-03-16 11:44:03 UTC ---
(In reply to comment #1)
> Integer overflow is causing undefined behaviour.  If you want wraparound
> semantics either use unsigned int or -fwrapv.

Hi, Hyun-Ho Kyeong,

More information about such undefined behavior~ :)

According to C99 standard:

C99 6.3.1.4 Point 1:
"... If the value of the integral part cannot be represented
 by the integer type, the behavior is undefined."

C99 6.5 Point 5:
"... if the result is ... not in the range of representable
 values for its type... the behavior is undefined."



More information about the Gcc-bugs mailing list