From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23553 invoked by alias); 6 Jun 2002 23:56:01 -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 23533 invoked by uid 71); 6 Jun 2002 23:56:01 -0000 Resent-Date: 6 Jun 2002 23:56:01 -0000 Resent-Message-ID: <20020606235601.23532.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, jason@cambridge.redhat.com Received:(qmail 19057 invoked from network); 6 Jun 2002 23:52:30 -0000 Received: from unknown (HELO executor.cambridge.redhat.com) (195.224.55.237) by sources.redhat.com with SMTP; 6 Jun 2002 23:52:30 -0000 Received: from prospero.cambridge.redhat.com (dell-paw-2.cambridge.redhat.com [195.224.55.226]) by executor.cambridge.redhat.com (Postfix) with ESMTP id AC90DABAF8 for ; Fri, 7 Jun 2002 00:52:29 +0100 (BST) Received: by prospero.cambridge.redhat.com (Postfix, from userid 4046) id 183D5F8D1D; Fri, 7 Jun 2002 00:52:19 +0100 (BST) Message-Id:<20020606235219.183D5F8D1D@prospero.cambridge.redhat.com> Date: Thu, 06 Jun 2002 16:56:00 -0000 From: jason@cambridge.redhat.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version:3.113 Subject: middle-end/6950: gcc 3.0.4 miscompiles cppexp.c X-SW-Source: 2002-06/txt/msg00135.txt.bz2 List-Id: >Number: 6950 >Category: middle-end >Synopsis: gcc 3.0.4 miscompiles cppexp.c >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Thu Jun 06 16:56:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Jason Merrill >Release: 3.0.4 >Organization: Red Hat, Inc. >Environment: System: Linux prospero.cambridge.redhat.com 2.4.9-31 #1 Tue Feb 26 07:11:02 EST 2002 i686 unknown Architecture: i686 host: i686-pc-linux-gnu build: i686-pc-linux-gnu target: i686-pc-linux-gnu configured with: /home/jason/eg/configure --with-gcc-version-trigger=/home/jason/eg/gcc/version.c --host=i686-pc-linux-gnu -v --with-dwarf2 --enable-threads=posix --with-as=/home/jason/s/sw/gas/as-new --with-ld=/home/jason/s/sw/ld/ld-new : (reconfigured) : (reconfigured) : (reconfigured) : (reconfigured) : (reconfigured) : (reconfigured) : (reconfigured) : (reconfigured) : (reconfigured) : (reconfigured) : (reconfigured) : (reconfigured) : (reconfigured) : (reconfigured) : (reconfigured) : (reconfigured) : (reconfigured) : (reconfigured) : (reconfigured) : (reconfigured) : (reconfigured) : (reconfigured) : (reconfigured) : (reconfigured) : (reconfigured) : (reconfigured) : (reconfigured) : (reconfigured) : (reconfigured) >Description: In Neil's recent changes to cppexp.c, num_equality_op stores the result of a && expression into a location which is used in the expression. gcc 3.0.4 wrongly generates code for this which first stores 0 into the target, then computes the expression, to poor result. This bug is not present in 2.95.3, Red Hat 2.96-98 or 3.1.0. I plan to work around this bug in the trunk sources, but it might still be a good idea to fix this in a 3.0.5 release. >How-To-Repeat: Here is a reduced testcase. typedef struct cpp_num cpp_num; struct cpp_num { long high; long low; char overflow; }; #define num_eq(num1, num2) (num1.low == num2.low && num1.high == num2.high) static cpp_num num_equality_op (lhs, rhs) cpp_num lhs, rhs; { lhs.low = num_eq (lhs, rhs); lhs.high = 0; lhs.overflow = 0; return lhs; } int main() { cpp_num a = { 1, 2 }; cpp_num b = { 3, 4 }; cpp_num result = num_equality_op (a, b); if (result.low) return 1; result = num_equality_op (a, a); if (!result.low) return 2; return 0; } >Fix: >Release-Note: >Audit-Trail: >Unformatted: