double (*parray[15])[];
friesen at psivax.UUCP
friesen at psivax.UUCP
Sun May 25 03:54:31 AEST 1986
In article <863 at cyb-eng.UUCP> topher at 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: ??
More information about the Comp.lang.c
mailing list