Eric Sosman said:
Eric Sosman said:
On 4/10/2010 12:49 PM, Tim Rentsch wrote:
If we have
int x[10][20];
then 'x[y]' is not an lvalue.
No, it *is* an lvalue (assuming a valid `y'). It's not a
"modifiable lvalue," but it's an lvalue. 6.3.2.1p1.
Surely you must know what I mean.
Apparently not. I mistook your "`x[y] is not an lvalue"
to mean that `x[y]' is not an lvalue. Sorry about that.
The expression
'x[y]' is an array and as such it is converted to
a pointer to the array's first element and is no
longer an lvalue. 6.3.2.1p3.
... which has nothing to do with the lvalue-ness of the
expression `x[y]'. It talks of the non-lvalue-ness of a value
*derived from* that expression in some contexts (those not
covered by the paragraph's first phrase, which begins with the
telltale word "Except").
It seems to me you're being deliberately obtuse. However, ignoring
that, your statement above is still at odds with the text in the
Standard. 6.3.2.1p3 (first sentence):
Except when it is the operand of the sizeof operator or the
unary & operator, or is a string literal used to initialize
an array, an expression that has type ``array of type'' is
converted to _an expression_ [emphasis added] with type
``pointer to type'' that points to the initial element of
the array object and is not an lvalue.
The Standard is talking about the lvalue-ness of an expression,
not of a value. Furthermore I think most C developers with some
exposure to the term 'lvalue' in it Standardese sense would say
the same thing -- given 'int x[10][20];', the expression 'x[10]'
doesn't behave the same way as a simple variable reference (which
is an lvalue), in that it doesn't designate an object, cause a
read access on the RHS of an assignment, etc[*] -- that is, it's
not an lvalue. Since the Standard agrees with my usage, and
since most other folks seem to know what I mean, your comments
left me rather baffled.
[*] Yes, for the nth time, whether 'x[10]' behaves as an
lvalue depends on context, such as '&x[10]' when it does.
My usage of 'x[10]' is meant to apply to the typical
cases, not the exceptional ones such as '&x[10]'.