This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c++/5724: Evaluation order of parameters for multiple operator<< calls



>Number:         5724
>Category:       c++
>Synopsis:       Evaluation order of parameters for multiple operator<< calls
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Feb 18 11:06:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Raoul Gough
>Release:        2.95.3-5
>Organization:
>Environment:
Cygwin on Windows 2000
>Description:
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.
>How-To-Repeat:
g++ gccseqtest.cc -o gccseqtest
./gccseqtest

Produces:
121
122

I think this should be:

122
122
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]