From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32351 invoked by alias); 11 Jan 2002 00:26: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 32313 invoked by uid 71); 11 Jan 2002 00:26:01 -0000 Resent-Date: 11 Jan 2002 00:26:01 -0000 Resent-Message-ID: <20020111002601.32312.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, Ben Liblit Received:(qmail 29484 invoked from network); 11 Jan 2002 00:19:45 -0000 Received: from unknown (HELO brawnix.CS.Berkeley.EDU) (128.32.131.103) by sources.redhat.com with SMTP; 11 Jan 2002 00:19:45 -0000 Received: (from liblit@localhost) by brawnix.CS.Berkeley.EDU (8.11.6/8.11.6) id g0B0JiF05064; Thu, 10 Jan 2002 16:19:44 -0800 Message-Id:<200201110019.g0B0JiF05064@brawnix.CS.Berkeley.EDU> Date: Thu, 10 Jan 2002 16:26:00 -0000 From: Ben Liblit To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version:3.113 Subject: c/5354: function call with two statement expressions yields incorrect result X-SW-Source: 2002-01/txt/msg00420.txt.bz2 List-Id: >Number: 5354 >Category: c >Synopsis: function call with two statement expressions yields incorrect result >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Thu Jan 10 16:26:00 PST 2002 >Closed-Date: >Last-Modified: >Originator: Ben Liblit >Release: 3.1 20020110 (experimental) >Organization: Computer Science Division, UC Berkeley >Environment: System: Linux brawnix.CS.Berkeley.EDU 2.4.17 #4 Fri Dec 28 23:34:16 PST 2001 i686 unknown Architecture: i686 host: i686-pc-linux-gnu build: i686-pc-linux-gnu target: i686-pc-linux-gnu configured with: ../src/configure --prefix=/var/local/liblit/gcc-cvs/install >Description: When calling a function where two arguments are computed using ({...}) statement expressions, the generated code computes the incorrect value for one of the arguments. Specifically, it appears that whichever statement expression is computed *last* is taken as the value for *both* arguments. >How-To-Repeat: Compile and run the following code: ------------------------------------------------------------------------ extern int printf(__const char *__restrict __format, ...); void f(int x, int y) { printf("f(%d, %d)\n", x, y); } int main() { f(({ int temp1 = 1; temp1; }), ({ int temp2 = 2; temp2; })); return 0; } ------------------------------------------------------------------------ gcc-2.96 produces the correct output: f(1, 2) gcc-3.0.1, which computes the arguments for the call to g from right to left, produces the following incorrect output: f(1, 1) gcc CVS snapshot as of 10-Jan-2002, which computes the arguments for the call to g from left to right, produces the following incorrect output: f(2, 2) >Fix: >Release-Note: >Audit-Trail: >Unformatted: