Where does the C standard describe overflow of signed integers?
Michael Meissner
gcc-mail@the-meissners.org
Tue Jul 12 23:13:00 GMT 2005
On Mon, Jul 11, 2005 at 09:58:36AM -0500, 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?
I don't have time to dig out all of the relevant sections, but I was on the
ANSI X3J11 committee that defined the C standard from its beginning through the
release of the C90 international standard (and some of the C99 work, though I
left the committee before a lot of the changes were made). It did come up for
discussion, but the committee did decide to leave it undefined, since there
were C compilers for some different machines that did not just silently
truncate.
>From memory, there was one vendor with a machine that had signed magnitude
integers.
There was a vendor with a machine that had one's complement integers.
I suspect at least one vendor used instructions that caused an overflow trap
for signed arithmetic.
--
Michael Meissner
email: gnu@the-meissners.org
http://www.the-meissners.org
More information about the Gcc
mailing list