public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/2673
@ 2001-04-29  8:46 Uwe F. Mayer
  0 siblings, 0 replies; 2+ messages in thread
From: Uwe F. Mayer @ 2001-04-29  8:46 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/2673; it has been noted by GNATS.

From: "Uwe F. Mayer" <mayer@tux.org>
To: <gcc-gnats@gcc.gnu.org>
Cc: <pme@gcc.gnu.org>
Subject: Re: c++/2673
Date: Sun, 29 Apr 2001 11:42:42 -0400 (EDT)

 I am withdrawing my bug report with Synopsis: c++ calls by value instead
 of by reference. It is not a bug but bad code. In the example code the
 call is actually made as a call-by-reference, it just happens that I am
 using "d" twice in the same statement, and the compiler can evaluate the
 pieces of the statement any way it seems fit. In this case "d" gets
 evaluated before the side-effect of the call to "f" occurs. This is
 similar to the old textbook example of not using j=++i+i, where the
 results are system dependent.
 
 #include <iostream>
 using namespace std;
 
 double f(double& x)
 { x=1; return 2; }
 
 int main() {
    double d=5;
    // bad code: the line below produces false output of "2    5"
    cout << f(d) << "\t" << d << endl;
    // the line below produces correct output of "2    1"
    cout << f(d); cout << "\t" << d << endl;
 }
 
 
 


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: c++/2673
@ 2001-04-28 18:36 pme
  0 siblings, 0 replies; 2+ messages in thread
From: pme @ 2001-04-28 18:36 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/2673; it has been noted by GNATS.

From: pme@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org, mayer@tosca.localnet, nobody@gcc.gnu.org
Cc:  
Subject: Re: c++/2673
Date: 29 Apr 2001 01:31:00 -0000

 Synopsis: c++ calls by value instead of by reference
 
 State-Changed-From-To: open->closed
 State-Changed-By: pme
 State-Changed-When: Sat Apr 28 21:31:00 2001
 State-Changed-Why:
     Thank you for your report.
     
     Note that "Priority: high" is reserved for GCC maintainers.
     
     This is not a bug.  There is no defined order of evaluation
     for a statement like
     
         cout << f(d) << "\t" << d << endl;
     
     so 'd' may be evaluated before 'f(d)'.
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=2673&database=gcc


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-04-29  8:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-29  8:46 c++/2673 Uwe F. Mayer
  -- strict thread matches above, loose matches on Subject: below --
2001-04-28 18:36 c++/2673 pme

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).