From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9109 invoked by alias); 27 Dec 2002 08:46:02 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 9090 invoked by uid 71); 27 Dec 2002 08:46:02 -0000 Resent-Date: 27 Dec 2002 08:46:02 -0000 Resent-Message-ID: <20021227084602.9089.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, geist@foobox.com Received: (qmail 8801 invoked by uid 61); 27 Dec 2002 08:41:17 -0000 Message-Id: <20021227084117.8797.qmail@sources.redhat.com> Date: Fri, 27 Dec 2002 00:46:00 -0000 From: geist@foobox.com Reply-To: geist@foobox.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: middle-end/9063: invalid compile-time evaluation of tertiary expression X-SW-Source: 2002-12/txt/msg01308.txt.bz2 List-Id: >Number: 9063 >Category: middle-end >Synopsis: invalid compile-time evaluation of tertiary expression >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Fri Dec 27 00:46:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: Travis Geiselbrecht >Release: gcc version 3.2.2 20021212 (Debian prerelease) >Organization: >Environment: Debian Linux 3.0 testing. x86 pc >Description: The following minimal program will reproduce if compiled with any levels of optimization. Problem: the expression (100000 + 1 ? 99 : 0) takes on a value of '99', instead of the expected 100099. A simple addition of parenthesis to produce (100000 + (1 ? 99 : 0)) produces the proper result. Not incredibly serious, but I bumped into it and took a while to figure out. Reproduced on 2.95.4, 3.0.4, and this 3.2.2 pre-release version in debian. Originally seen on 3.0.4 i386. >How-To-Repeat: # 1 "bug.c" # 1 "" # 1 "" # 1 "bug.c" int main() { printf("value of expression %d should be %d\n", (100000 + 1 ? 99 : 0), (100000 + (1 ? 99 : 0))); return 0; } >Fix: Add parentheses around the tertiary operator. >Release-Note: >Audit-Trail: >Unformatted: