From 220968523748258924
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,7522e5259f7267d6
X-Google-Attributes: gidf78e5,public
From: Zalman Stern <zalman@netcom9.netcom.com>
Subject: Re: x = y = z; Undefined?
Date: 2000/01/14
Message-ID: <85mtg5$ii6$1@nntp6.atl.mindspring.net>#1/1
X-Deja-AN: 572517421
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
References: <3874B57E.CC4CD74B@fnal.gov>
X-Trace: mail2news.demon.co.uk 947849125 mail2news:25313 mail2news mail2news.demon.co.uk
Organization: MindSpring Enterprises
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Authentication-Warning: backdraft.briar.org: smap set sender to <news@nntp6.atl.mindspring.net> using -f
User-Agent: tin/pre-1.4-19990517 ("Psychonaut") (UNIX) (SunOS/4.1.4 (sun4m))
Newsgroups: comp.std.c++
X-Complaints-To: abuse@demon.net

Walter E Brown <wb@fnal.gov> wrote:
:     void f( T & t );
:     /* ... */
:     f( x = y );
[...]

I had to deal with such a piece of code a few years ago. Many C++
programmers I asked believed it is required to pass a reference to x as
the argument to f. The Metrowerks compiler of the time disagreed and
Metrowerks defended the decision as draft standard compliant. The standard
at the time said the assignment returned an lvalue of the appropriate
type having the appropriate value. It did not say that the same lvalue that
was assigned to had to be returned. I believe section 5.17 of the actual
standard reads the same way.

A number of smart people agreed that the standard did not make this
explicit and I concluded that you *never* want to write code like that.
Can't see how anything has changed here for the final standard.

Andrew Koenig's post indicates that the intent of the standard is that a
reference to x is required above, but there is certainly some contention
about whether that intent is expressed in the language of the standard.

-Z-

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]




