home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / c / 16566 < prev    next >
Encoding:
Text File  |  1992-11-15  |  1.8 KB  |  49 lines

  1. Newsgroups: comp.lang.c
  2. 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
  3. From: eager@eagercon.com (Michael J. Eager)
  4. Subject: Re: & of array - what does ANSI specify for resulting value?
  5. Message-ID: <1992Nov15.184422.2077@eagercon.com>
  6. Sender: root@eagercon.com (Operator)
  7. Reply-To: eager@eagercon.com
  8. Organization: Eager Consulting
  9. References: <27456@dog.ee.lbl.gov>
  10. Date: Sun, 15 Nov 1992 18:44:22 GMT
  11. Lines: 36
  12.  
  13. In article 27456@dog.ee.lbl.gov, torek@horse.ee.lbl.gov (Chris Torek) writes:
  14. >Others have posted the correct answer, but ...
  15. >
  16. >>>>[given] int foo[3]; [what is &foo?]
  17. >
  18. >In article <1992Nov13.205510.26280@eagercon.com> eager@eagercon.com writes:
  19. >>ANSI sect 3.3.3.2 says "The operand of the unary & shall be ... an lvalue".
  20. >
  21. >So far so good...
  22. >
  23. >>foo is an rvalue,
  24. >
  25. >No, in ANSI terminology, `foo' is a `non-modifiable lvalue'.  (I prefer
  26. >to say that foo is an `object', an object being something that lives in
  27. >some kind of memory, and holds values.  This seems more self-explanatory
  28. >than `lvalue is a contraction of left-value'.)
  29. >
  30. >>there is no object for the & operator to take the address of.
  31. >
  32. >`foo' becomes a value (`rvalue' in ANSI terminology) only in value
  33. >contexts.  Unary `&' does not provide a value context, so `foo' stays
  34. >an object.  Thus &foo is legal, and (given the declaration above) has
  35. >type `pointer to array 3 of int', or `int (*)[3]'.
  36. >
  37. >Note that in Classic (pre-ANSI) C, the situation was slightly different.
  38.  
  39.  
  40. Mea culpa.  I should know better.  Yes, an array is an non-modifiable lvalue.
  41. I had forgotten that the array is not converted for &.
  42.  
  43.  
  44. ---
  45. Michael J. Eager        Michael.Eager@eagercon.com
  46. Eager Consulting        (415) 325-8077 
  47. 1960 Park Boulevard, Palo Alto, CA 94306-1141
  48.  
  49.