From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4974 invoked by alias); 14 Jul 2005 19:13:58 -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 4960 invoked by uid 22791); 14 Jul 2005 19:13:55 -0000 Received: from nile.gnat.com (HELO nile.gnat.com) (205.232.38.5) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Thu, 14 Jul 2005 19:13:55 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-nile.gnat.com (Postfix) with ESMTP id BDFC59664; Thu, 14 Jul 2005 15:13:53 -0400 (EDT) Received: from nile.gnat.com ([127.0.0.1]) by localhost (nile.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 17863-01-9; Thu, 14 Jul 2005 15:13:53 -0400 (EDT) Received: from [127.0.0.1] (taconic.gnat.com [205.232.38.103]) by nile.gnat.com (Postfix) with ESMTP id 73F7A9617; Thu, 14 Jul 2005 15:13:53 -0400 (EDT) Message-ID: <42D6B970.1090903@adacore.com> Date: Thu, 14 Jul 2005 19:13:00 -0000 From: Robert Dewar User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) MIME-Version: 1.0 To: Paul Schlie CC: Matthew Woodcraft , 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/msg00609.txt.bz2 Paul Schlie wrote: >>What about optimising x*2/2 to x? > > > Given that "C" requires the above be evaluated as (x*2)/2, as the language > specifies that the syntax defines the precedence of the operations, and that > no optimization should alter the behavior as specified by the program; I'd > say that unless it was known that the value range of x was between 0 > and INT_MAX, the optimization is simply invalid. the optimization is indeed valid optimizations may most certainly alter behavior of undefined code. think about uninitialized local variables.