home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!europa.asd.contel.com!emory!swrinde!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!unixhub!ditka!eagercon!eagercon!eager
- From: eager@eagercon.com (Michael J. Eager)
- Subject: Re: & of array - what does ANSI specify for resulting value?
- Message-ID: <1992Nov15.184422.2077@eagercon.com>
- Sender: root@eagercon.com (Operator)
- Reply-To: eager@eagercon.com
- Organization: Eager Consulting
- References: <27456@dog.ee.lbl.gov>
- Date: Sun, 15 Nov 1992 18:44:22 GMT
- Lines: 36
-
- In article 27456@dog.ee.lbl.gov, torek@horse.ee.lbl.gov (Chris Torek) writes:
- >Others have posted the correct answer, but ...
- >
- >>>>[given] int foo[3]; [what is &foo?]
- >
- >In article <1992Nov13.205510.26280@eagercon.com> eager@eagercon.com writes:
- >>ANSI sect 3.3.3.2 says "The operand of the unary & shall be ... an lvalue".
- >
- >So far so good...
- >
- >>foo is an rvalue,
- >
- >No, in ANSI terminology, `foo' is a `non-modifiable lvalue'. (I prefer
- >to say that foo is an `object', an object being something that lives in
- >some kind of memory, and holds values. This seems more self-explanatory
- >than `lvalue is a contraction of left-value'.)
- >
- >>there is no object for the & operator to take the address of.
- >
- >`foo' becomes a value (`rvalue' in ANSI terminology) only in value
- >contexts. Unary `&' does not provide a value context, so `foo' stays
- >an object. Thus &foo is legal, and (given the declaration above) has
- >type `pointer to array 3 of int', or `int (*)[3]'.
- >
- >Note that in Classic (pre-ANSI) C, the situation was slightly different.
-
-
- Mea culpa. I should know better. Yes, an array is an non-modifiable lvalue.
- I had forgotten that the array is not converted for &.
-
-
- ---
- Michael J. Eager Michael.Eager@eagercon.com
- Eager Consulting (415) 325-8077
- 1960 Park Boulevard, Palo Alto, CA 94306-1141
-
-