From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1123 invoked by alias); 5 Jan 2007 20:32:48 -0000 Received: (qmail 1089 invoked by uid 48); 5 Jan 2007 20:32:38 -0000 Date: Fri, 05 Jan 2007 20:32:00 -0000 Message-ID: <20070105203238.1088.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug middle-end/30364] [4.1/4.2/4.3 Regression] Wrong variable ranges due to constant folding In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "pinskia at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-01/txt/msg00325.txt.bz2 ------- Comment #7 from pinskia at gcc dot gnu dot org 2007-01-05 20:32 ------- >>From C99, 5.1.2.3/14: 14 EXAMPLE 6 To illustrate the grouping behavior of expressions, in the following fragment int a, b; /* ... */ a = a + 32760 + b + 5; the expression statement behaves exactly the same as a = (((a + 32760) + b) + 5); due to the associativity and precedence of these operators. Thus, the result of the sum (a + 32760) is next added to b, and that result is then added to 5 which results in the value assigned to a. On a machine in which overflows produce an explicit trap and in which the range of values representable by an int is [−32768, +32767], the implementation cannot rewrite this expression as a = ((a + b) + 32765); since if the values for a and b were, respectively, −32754 and −15, the sum a + b would produce a trap while the original expression would not; nor can the expression be rewritten either as a = ((a + 32765) + b); or a = (a + (b + 32765)); since the values for a and b might have been, respectively, 4 and −8 or −17 and 12. However, on a machine in which overflow silently generates some value and where positive and negative overflows cancel, the above expression statement can be rewritten by the implementation in any of the above ways because the same result will occur. That is most explict thing about overflow and groupping. In C, every expression has an implicate parenthesises. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30364