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.
i = ++ i
, and introducing reference variables (j
here) to duplicate such lvalues so their evaluation is not nominally affected by side effects. – Silence