🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3026

Re: Contradiction wrt arrays

#3026
From: Norman Diamond
Date: Tue, 15 Dec 1992 05:01
31 lines
1915 bytes
In article <1gj22rINNe9d@falcon.natinst.com> erik@natinst.com (Erik Crank) writes:
>        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 [...]
[...]
>By "is legal" I mean "has defined behavior".
>My reasoning is as follows:
>        1. &a[N] is valid iff &(*(a+N)) is valid.
>           (by definition of array subscripting [3.3.2.1])

Yup.

>        2. &(*(a+N)) is valid iff *(a+N) is valid.
>           (by definition of indirection operator [3.3.3.2])

By definition of address operator [also 3.3.3.2], &(*(a+N)) is valid iff
*(a+N) is either a function designator or an lvalue that designates an
object that is not a bit-field and is not declared with the register
storage-class specifier.  In fact, *(a+N) is not a function designator
and is not an lvalue that designates an object.

Therefore &a[N] is invalid.  You've proven that the Rationale is wrong
here.  Fortunately (:-s) the Rationale isn't part of the Standard.

The desired result can be obtained by the expression a+N.
--
Norman Diamond       diamond@jit081.enet.dec.com
If this were the company's opinion, I wouldn't be allowed to post it.
"It's been a lovely recession."
Technical Details
Message-ID: <BzABB1.HB7@jrd.dec.com>
Path: arc1-ca.pugleaf.net!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
References: <1gj22rINNe9d@falcon.natinst.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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
From: diamond@jit533.jit.dec.com (Norman Diamond)
Newsgroups: comp.std.c
Subject: Re: Contradiction wrt arrays
Message-ID: <BzABB1.HB7@jrd.dec.com>
Date: 15 Dec 92 05:01:49 GMT
References: <1gj22rINNe9d@falcon.natinst.com>
Sender: usenet@jrd.dec.com (USENET News System)
Reply-To: diamond@jit.dec.com (Norman Diamond)
Organization: Digital Equipment Corporation Japan , Tokyo
Lines: 31
Nntp-Posting-Host: jit533.jit.dec.com