What's an LValue [was A quick question]

Jim Lyon jimbo at tandem.com
Wed Mar 13 15:05:55 AEST 1991


In article <31306 at shamash.cdc.com> bls at u02.svl.cdc.com (Brian Scearce) writes:
>The rules are pretty easy (especially if you have your copy of
>Harbison and Steele on your desk :-)
>
>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...

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".

-- Jim Lyon
   jimbo at Tandem.Com



More information about the Comp.lang.c mailing list