Subject: Re: standards/5959: c++ language specification error or compiler error??
To: Andrew Brown <twofsonet@graffiti.com>
From: Guenther Grau <Guenther.Grau@bk.bosch.de>
List: netbsd-bugs
Date: 08/18/1998 18:42:39
Andrew Brown wrote:
> 
> >> an "assignment" usually yields an rvalue (unless you write a c++ class
> >> that returns a non-const reference from operator=(), which is yet
> >> another way to make your code confusing :), ie:
> >
> >The 2 December 1996 Working Paper for the C++ standard (the last
> >public review draft) section 5.17 [expr.ass] says:
> >
> >1 There are several assignment operators, all of which  group  right-to-
> >  left.   All require a modifiable lvalue as their left operand, and the
> >  type of an assignment expression is that of  its  left  operand.   The
> >  result  of  the  assignment  operation is the value stored in the left
> >  operand after the assignment has taken place; the result is an lvalue.
> >                                                ^^^^^^^^^^^^^^^^^^^^^^^
> 
> well...that's more or less the argument i was looking for.  thanks.
> :)

While this does explain, that you can take a reference from it, it
does not explain, why the reference is to the variable foo. Instead
it should be a reference to an anonymous variable, which contains the
result of the assignment, not to the variable being assigned to.
(I _do_ think however, that the result of an assignment should NOT
be an lvalue, but this is a different story :-)

  Guenther