pointers to arrays

Guy Harris guy at auspex.UUCP
Sat Feb 18 19:56:53 AEST 1989


>It looks to me as though given:
>	int flimflam[20];
>that &flimflam has type address of int.

Not in dpANS C; it has type "pointer to array of 20 'int's".  It has
that type in C as implemented by most PCC-based implementations.

>I maintain that if flimflam is an array [20] of int, then &flimflam
>is "address of array [20] of int."

And the dpANS (and probably the pANS, of which I don't yet have a copy)
agrees with you.

>I couldn't see X3J11 supporting a rewrite of arrays, but I don't believe
>that defining &array to return pointer to array would hurt existing
>programs, they get warnings in most cases anyway.

X3J11 probably didn't believe it either, which is why "&array" is
supposed to have the type "pointer to array...".  Basically,
"array-valued expressions" are converted to "pointer to first element of
array" in most, but not all, contexts; "operand of 'sizeof'" and
"operand of unary &" are contexts in which this conversion isn't done. 
Check your (d)pANS copy again; it's there (at least it's in the May 13,
1988 draft, and I'd be surprised as hell if it disappeared subsequently).



More information about the Comp.lang.c mailing list