"BartC" <email@example.com> writes:
> "Keith Thompson" <firstname.lastname@example.org> wrote in message
>> Harald van Dijk <email@example.com> writes:
>>> [ Legality of a++ = 1 ]
>>> No, it's always a value. If you can come up with a concrete sane
>>> proposal for making a++ an lvalue and a description of what the
>>> semantics should be, preferably without breaking existing valid code,
>>> I will be very impressed.
>> For what it's worth, in C++ ++a is an lvalue (but a++ isn't).
> How would the ++a work? Like this:
> int a=1000;
> ++a += 3; // a is now 1004?
I get 1004 using the g++ compiler -- but as in C, modifying an object
twice without an intervening sequence point has undefined behavior.
I think the usefulness of allowing ++a to be an lvalue shows up when
"++" is an overloaded operator.
Keith Thompson (The_Other_Keith) firstname.lastname@example.org
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"