public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: Ben Liblit <liblit@cs.berkeley.edu> To: gcc-gnats@gcc.gnu.org Subject: c/5354: function call with two statement expressions yields incorrect result Date: Thu, 10 Jan 2002 16:26:00 -0000 [thread overview] Message-ID: <200201110019.g0B0JiF05064@brawnix.CS.Berkeley.EDU> (raw) >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 <liblit@cs.berkeley.edu> >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:
next reply other threads:[~2002-01-11 0:26 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-01-10 16:26 Ben Liblit [this message] 2002-03-20 18:06 rth 2002-03-21 1:42 rth
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=200201110019.g0B0JiF05064@brawnix.CS.Berkeley.EDU \ --to=liblit@cs.berkeley.edu \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).