What's an LValue [was A quick question]

Stanley Friesen sarima at tdatirv.UUCP
Fri Mar 15 02:16:39 AEST 1991


In article <1991Mar13.050555.26149 at tandem.com> jimbo at tandem.com (Jim Lyon) writes:
<In article <31306 at shamash.cdc.com> bls at u02.svl.cdc.com (Brian Scearce) writes:
<>0. variable names (excepting function, array and enum constant
<>   names) are lvalues.
<>1. e[k] is an lvalue, regardless of whether e and k are lvalues.
<>2. (e) is an lvalue iff e is.
<>3. e.name is an lvalue iff e is.
<>4. e->name is an lvalue regardless of whether e is an lvalue.
<>5. *e is an lvalue regardless of whether e is an lvalue.
<
<Rules (1) and (5) need to be further qualified.  e[k] and *e are
<lvalues regardless of whether e and k are lvalues, UNLESS the type
<of e[k] or *e is either Array... or Function...

Well, as I understand the ANSI definition of lvalue (different than the
K&R1 definition), the original rules are correct as stated.  It is just
that in that case the result is not a *modifiable* lvalue, and is converted
in all value contexts into a pointer to the object.

<For example, if A is declared as "int A[10][10]", then "A[5]"
<is not an lvalue, because the type of "A[5]" is "Array of int".

Or rather, by ANSI definitions, it *is* an lvalue that is immediately
converted into a non-lvalue pointer of type "Pointer to int".
-- 
---------------
uunet!tdatirv!sarima				(Stanley Friesen)



More information about the Comp.lang.c mailing list