From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15706 invoked by alias); 12 Jul 2005 23:13:33 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 15418 invoked by uid 22791); 12 Jul 2005 23:12:51 -0000 Received: from metal-man.the-meissners.org (HELO tiktok.the-meissners.org) (66.205.90.83) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Tue, 12 Jul 2005 23:12:51 +0000 Received: from tiktok.the-meissners.org (localhost [127.0.0.1]) by tiktok.the-meissners.org (8.12.11/8.12.11) with ESMTP id j6CN71cs007033 for ; Tue, 12 Jul 2005 19:07:01 -0400 Received: (from meissner@localhost) by tiktok.the-meissners.org (8.12.11/8.12.11/Submit) id j6CN71bX007032 for gcc@gcc.gnu.org; Tue, 12 Jul 2005 19:07:01 -0400 Date: Tue, 12 Jul 2005 23:13:00 -0000 From: Michael Meissner To: gcc@gcc.gnu.org Subject: Re: Where does the C standard describe overflow of signed integers? Message-ID: <20050712230701.GB6903@tiktok.the-meissners.org> Mail-Followup-To: Michael Meissner , gcc@gcc.gnu.org References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.1i X-SW-Source: 2005-07/txt/msg00533.txt.bz2 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