home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / std / c / 3211 < prev    next >
Encoding:
Internet Message Format  |  1992-12-15  |  1.8 KB

  1. Path: sparky!uunet!olivea!spool.mu.edu!agate!ames!decwrl!deccrl!news.crl.dec.com!dbased.nuo.dec.com!e2big.mko.dec.com!jrdzzz.jrd.dec.com!jit533.jit.dec.com!diamond
  2. From: diamond@jit533.jit.dec.com (Norman Diamond)
  3. Newsgroups: comp.std.c
  4. Subject: Re: Contradiction wrt arrays
  5. Message-ID: <BzABB1.HB7@jrd.dec.com>
  6. Date: 15 Dec 92 05:01:49 GMT
  7. References: <1gj22rINNe9d@falcon.natinst.com>
  8. Sender: usenet@jrd.dec.com (USENET News System)
  9. Reply-To: diamond@jit.dec.com (Norman Diamond)
  10. Organization: Digital Equipment Corporation Japan , Tokyo
  11. Lines: 31
  12. Nntp-Posting-Host: jit533.jit.dec.com
  13.  
  14. In article <1gj22rINNe9d@falcon.natinst.com> erik@natinst.com (Erik Crank) writes:
  15. >        char a[N];
  16. >(1)     &a[N];
  17. >(2)     a[N];
  18. >If expression (1) is legal (which is implied by the Rationale 3.3.6)
  19. >then I claim that expression (2) should also be legal, although it isn't [...]
  20. [...]
  21. >By "is legal" I mean "has defined behavior".
  22. >My reasoning is as follows:
  23. >        1. &a[N] is valid iff &(*(a+N)) is valid.
  24. >           (by definition of array subscripting [3.3.2.1])
  25.  
  26. Yup.
  27.  
  28. >        2. &(*(a+N)) is valid iff *(a+N) is valid.
  29. >           (by definition of indirection operator [3.3.3.2])
  30.  
  31. By definition of address operator [also 3.3.3.2], &(*(a+N)) is valid iff
  32. *(a+N) is either a function designator or an lvalue that designates an
  33. object that is not a bit-field and is not declared with the register
  34. storage-class specifier.  In fact, *(a+N) is not a function designator
  35. and is not an lvalue that designates an object.
  36.  
  37. Therefore &a[N] is invalid.  You've proven that the Rationale is wrong
  38. here.  Fortunately (:-s) the Rationale isn't part of the Standard.
  39.  
  40. The desired result can be obtained by the expression a+N.
  41. --
  42. Norman Diamond       diamond@jit081.enet.dec.com
  43. If this were the company's opinion, I wouldn't be allowed to post it.
  44. "It's been a lovely recession."
  45.