P
Philip Potter
Willem said:Philip wrote:
) That's exactly the point I was making too. I was saying that a.b is
) conditionally an lvalue based on a, so why not have a?b:c conditionally
) an lvalue based on b and c?
Correct me if I'm wrong, but isn't a.b *always* an lvalue in C ?
You are wrong according to n1256 6.5.2.3p3:
A postfix expression followed by the . operator and an identifier
designates a member of a structure or union object. The value is that of
the named member, and is an lvalue if the first expression is an
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lvalue. If the first expression has qualified type, the result has the
^^^^^^^
so-qualified version of the type of the designated member.
An example of where this matters:
struct a { int b; } inst_a;
struct a f(void) { inst_a.b = 0; return inst_a; }
int main(void) {
f().b = 10; /* error - f().b is not an lvalue */
return f().b; /* okay - f().b is an rvalue */
}