This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Fixing the wrapping issue
> Thanks for the pointer. This says:
>
> @cite{The result of, or the signal raised by, converting an integer to a
> signed integer type when the value cannot be represented in an object of
> that type (C90 6.2.1.2, C99 6.3.1.3).}
>
> For conversion to a type of width @math{N}, the value is reduced
> modulo @math{2^N} to be within range of the type; no signal is raised.
>
Then there is your answer.
We have defined signed conversions to effectively wrap.
This is what icc does as well in this case, and i imagine most C
compilers.