home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!natinst.com!natinst.com!not-for-mail
- From: erik@natinst.com (Erik Crank)
- Newsgroups: comp.std.c
- Subject: Contradiction wrt arrays
- Date: 14 Dec 1992 16:32:59 -0600
- Organization: National Instruments, Austin, TX
- Lines: 31
- Message-ID: <1gj22rINNe9d@falcon.natinst.com>
- NNTP-Posting-Host: falcon.natinst.com
-
-
- I'm wondering about an apparent contradiction in the standard
- concerning addressing "one past the last element" of an array.
-
- Consider the following expressions:
- {
- char a[N];
-
- (1) &a[N];
- (2) a[N];
- }
-
- If expression (1) is legal (which is implied by the Rationale 3.3.6)
- then I claim that expression (2) should also be legal, although it
- isn't according to the standard (3.3.6).
-
- My reasoning is as follows:
- 1. &a[N] is valid iff &(*(a+N)) is valid.
- (by definition of array subscripting [3.3.2.1])
-
- 2. &(*(a+N)) is valid iff *(a+N) is valid.
- (by definition of indirection operator [3.3.3.2])
-
- 3. *(a+N) is valid iff a[N] is valid.
- ([3.3.2.1])
- ---------------------
- 4. &a[N] is valid iff a[N] is valid. (by 1,2,3)
-
-
- By "is legal" I mean "has defined behavior".
-
-