Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!decwrl!pyramid!hplabs!sdcrdcf!psivax!friesen From: friesen@psivax.UUCP Newsgroups: net.lang.c,net.micro.pc Subject: Re: double (*parray[15])[]; Message-ID: <1220@psivax.UUCP> Date: Sat, 24-May-86 13:54:31 EDT Article-I.D.: psivax.1220 Posted: Sat May 24 13:54:31 1986 Date-Received: Mon, 26-May-86 01:53:52 EDT References: <200@pyuxv.UUCP> <1181@ncoast.UUCP> <350@dg_rtp.UUCP> <3423@ukma.UUCP> <863@cyb-eng.UUCP> Reply-To: friesen@psivax.UUCP (Stanley Friesen) Organization: Pacesetter Systems Inc., Sylmar, CA Lines: 43 Xref: watmath net.lang.c:9150 net.micro.pc:8400 In article <863@cyb-eng.UUCP> topher@cyb-eng.UUCP (Topher Eliot) writes: >There has been some debate on what the declaration > double (*parray[15])[]; >means. David Herron seems to be arguing that it declares a zero-length >array of some sort, which some people and/or compilers might interpret as >being a pointer of the same sort. [Topher Eliot's parse] > > double (*parray[15])[]; > ^^^^ >1. It's an array with 15 elements > > double (*parray[15])[]; > ^^^^^^^^^^^ >2. It's an array of 15 pointers. > > double (*parray[15])[]; > ^^^^^^^^^^^^^^^ >3. It's an array of 15 pointers to arrays (the sizes of these arrays being >pointed at is not specified). > > double (*parray[15])[]; > ^^^^^^^^^^^^^^^^^^^^^^ >4. It's an array of 15 pointers to arrays of doubles. > This is indeed correct, and the problem with this declaration stems from #3. The declaration declares an array of pointers to entities of *undefined* size(not zero size). Due to the way pointer arithmetic is defined in "C" this is not kosher(the compiler cannot determine how much to add to the pointer). At least one compiler I know of "accepts" this declaration by treating the unspecified arrays as having size 1, thus making the declaration eqiuvalent to: double *parray[15]; /* Array of pointers to double */ Since this is likely what the user really wanted anyway this works out, but it is still wrong! -- Sarima (Stanley Friesen) UUCP: {ttidca|ihnp4|sdcrdcf|quad1|nrcvax|bellcore|logico}!psivax!friesen ARPA: ??