Subject: Re: standards/5959: c++ language specification error or compiler error??
To: Daniel S. Riley <dsr@mail.lns.cornell.edu>
From: Andrew Brown <twofsonet@graffiti.com>
List: netbsd-bugs
Date: 08/13/1998 13:32:13
>> 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.
:)

>Since the (draft) standard explicitly specifies that the result of the
>assignment operator is an lvalue, not only is your example legal, so
>is
>
>   (foo=3) = 5;
>
>and according to the standard, so is
>
>   (foo == 0 ? bar : baz) = 5;

now...the second one i get, and i've used.  but the first one doesn't
work at all in c (gcc says "invalid lvalue in assignment") and i just
figured that it wouldn't work in c++.  if c++ says the result of an
assignement is an lvalue, then that's fine with me.  :)

>I imagine there is some terribly good reason for all this, but you'd
>have to ask on comp.std.c++ to find out what it is.

sure.  so that i can go on doing more and more goofy things.  (see
appendix c, section 2, paragraph 7: "allow andrew to do more and more
goofy things." :)

ps - where can i find a copy of that "working paper"?  or do i have to
pay for it?

-- 
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org             * "ah!  i see you have the internet
twofsonet@graffiti.com (Andrew Brown)                that goes *ping*!"
warfare@graffiti.com      * "information is power -- share the wealth."