In the Standard N1570, Section 6.5.3.2#3
the following is specified (emp. mine):
If the operand is the result of a unary * operator, neither that operator nor the & operator is evaluated and the result is as if both were omitted, except that the constraints on the operators still apply and the result is not an lvalue.
Later on the section 6.5.3.2#4
specifies:
If the operand points to a function, the result is a function designator; if it points to an object, the result is an lvalue designating the object.
This two sections look contradictory to me. The first on I cited specifies that the result is not an lvalue
, but the second one specifies that the result of indirection operator is an lvalue.
Can you please explain this? Does it mean that in case of object the operators *
and &
does not eliminate each other?
Section 6.5.3.2#3 talks about the unary &
operator and the 6.5.3.2#4 talks about the unary *
operator. They have different behaviors.
Elaboration (from comment):
The point is that unary &
does not result in an lvalue, even in the case where it is considered omitted because it immediately precedes unary *
in a dereference context. Just because both operators are considered omitted doesn't change the fact the resulting expression is not an lvalue; the same way it would not be if a solo unary &
were applied.
int a;
&a = ...;
is not legal (obviously). But neither is
int a;
&*a = ...;
Just because they are considered omitted doesn't mean &*
is lvalue-equivalent to solo a
.