Where does the C standard describe overflow of signed integers?
Nathan Sidwell
nathan@codesourcery.com
Mon Jul 11 15:15:00 GMT 2005
Nicholas Nethercote wrote:
> Hi,
>
> There was recently a very long thread about the overflow behaviour of
> signed integers in C. Apparently this is undefined according to the C
> standard. I searched the standard on this matter, and while I did find
> some paragraphs that described how unsigned integers must wrap around
> upon overflow, I couldn't find anything explicit about signed integers.
> Can someone point me to the relevant part(s) of the standard?
c99 6.5 para 5 (overflow is undefined) & 6.3.1.3 (conversions to unsigned type
obey modulo laws)
c++ 5 para 5 (overflow is undefined, unless otherwise stated) & 3.9.1 para 4
(unsigned types obey modulo laws)
I cannot find, in c99, a statement that all unsigned arithmetic obeys modulo
laws -- only that integral conversions to them do.
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
More information about the Gcc
mailing list