User account creation filtered due to spam.

Bug 5724

Summary: Evaluation order of parameters for multiple operator<< calls
Product: gcc Reporter: raoulgough
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: normal CC: gcc-bugs, grahams, nathan
Priority: P3    
Version: 2.95.3   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:

Description raoulgough 2002-02-18 11:06:00 UTC
I have an example where

cout << f(a) << f(b);

is calling f(b) before f(a), which I think is wrong. The operator<< is (in this case) a function call, so there should be a sequence point which guarantees evaluation order.

My apologies for submitting a bug on an old version.

Release:
2.95.3-5

Environment:
Cygwin on Windows 2000

How-To-Repeat:
g++ gccseqtest.cc -o gccseqtest
./gccseqtest

Produces:
121
122

I think this should be:

122
122
Comment 1 Nathan Sidwell 2002-02-18 13:47:14 UTC
State-Changed-From-To: open->closed
State-Changed-Why: no, there is no sequence point there. The code is
    equivalent of
    	output (output (cout, f (a)), f (b));
    where 'output' is the operator<< function. you'll see
    that 'f (b)' can be called before or after
    'output (cout, f (a))'
Comment 2 grahams 2002-02-18 20:18:34 UTC
From: Graham Stott <grahams@redhat.com>
To: RaoulGough@dial.pipex.com
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c++/5724: Evaluation order of parameters for multiple operator<< 
 calls
Date: Mon, 18 Feb 2002 20:18:34 +0000

 Please supply a complete testcase.
Comment 3 Wolfgang Bangerth 2004-08-13 16:01:30 UTC
Reopening to mark as a duplicate of... 
Comment 4 Wolfgang Bangerth 2004-08-13 16:03:36 UTC
...PR 11751. 

*** This bug has been marked as a duplicate of 11751 ***