As per @Potatoswatter’s suggestion, I have created a new discussion.
Reference is this response from @Potatoswatter
Given the code snippet,
int i = 3, &j = i;
j = ++ i;
The comment which I seek clarity on, is this. (which seems to be an important missing piece in my understanding of the unsequenced evaluation a.k.a sequence point):
@Chubsdad: Even though it’s an alias,
its glvalue evaluation does not
require a glvalue evaluation of i.
Generally speaking, evaluating a
reference does not require the
original object to be on hand. There’s
no reason it should be UB, so it makes
sense there should be an easy loophole
or transformation to code which is not
UB.
and
The reference doesn’t tell the
compiler to go look at the referenced
variable and get its lvalue, because
it might not know what variable is
referenced. The compiler computes the
lvalue of the reference and that
lvalue identifies an object. If you
want to debate this further, please
open a new question.
Any possible lack of clarity in the question is part of the ‘undefined behavior’ I am going through trying to understand ‘unsequenced evaluation’, ‘sequence point’ etc in C++0x.
Imagine the following
If you say that
iis an alias for another name – what name? A reference either references an object or function. When you say “glvalue”, you refer to a property of a particular expression, not to a property of an object.Now,
iis an lvalue expression andriis an lvalue expression too (both of the syntactic categoryid-expression). They name (as found by name-lookup) a reference and anintvariable.If you now determine the object identity for the
ricase, you need to take the reference and make the expression refer to the object it was initialized with. This is called an lvalue evaluation because you determine the property of an lvalue (i.e the referent).You need to do the same for the
icase. I.e you figure out to what object the lvalue expressionirefers to. A glvalue evaluation ofrithus is different than glvalue evaluation ofi, despite both of them yielding the same result.Rvalue evaluation means to take an lvalue and apply the lvalue to rvalue conversion. In other words, to read a value.