From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32548 invoked by alias); 11 Jul 2005 15:15:10 -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 32516 invoked by uid 22791); 11 Jul 2005 15:15:04 -0000 Received: from dumbledore.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.11) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Mon, 11 Jul 2005 15:15:04 +0000 Received: (qmail 2387 invoked from network); 11 Jul 2005 15:15:02 -0000 Received: from unknown (HELO ?192.168.189.167?) (nathan@127.0.0.2) by mail.codesourcery.com with ESMTPA; 11 Jul 2005 15:15:02 -0000 Message-ID: <42D28CFF.6040208@codesourcery.com> Date: Mon, 11 Jul 2005 15:15:00 -0000 From: Nathan Sidwell User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050404) MIME-Version: 1.0 To: Nicholas Nethercote CC: gcc@gcc.gnu.org Subject: Re: Where does the C standard describe overflow of signed integers? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2005-07/txt/msg00416.txt.bz2 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