Followup to Very Tough C Riddle

Joseph S. D. Yao jsdy at hadron.UUCP
Thu May 8 23:29:43 AEST 1986


AARRGGHHHHHHHHHHH!!!!!

In article <140 at delftcc.UUCP> sam at delftcc.UUCP (Sam Kendall) writes:
>     Even though it's not necessary for the riddle's solution, let's
>take a look at the other possibility, which is for there to be a formal
>parameter declaration of the form
>        type formal[][];
>Tony Li and Joe Yao mentioned this possibility, but they didn't think
>it was legal.  The passage mentioned in K&R that many people think
>prohibits any adjacent pairs of empty brackets is this:
>        multi-dimensional array ...		may be missing only for
>        the first member of the sequence.  (section 8.4)
>The passage that may allow `[ ] [ ]' for formal parameters is this
>(first elipsis mine):  [other ellipses mine -jsdy-]
>        ...  [D]eclarations of formal parameters declared "array of ..."
>        are adjusted to read "pointer to ...".  (section 10.1)
>    ... type formal[][]; "is adjusted to read" type (*formal)[];
>This second type is "pointer to array of unknown length".

Sam, this is not legal, has never been legal, and (pray God) will
never be legal.  One may have the first member of the [] sequence
empty because, from the rest, one can determine the size of each
member of the array.  One may not have pointers to or arrays of
items of which one does not know the size.  To see why this is so,
tell me: what do arrname[1] or *++ptr reference????

By the way -- section 10.1 cited above refers, of course only to the
outermost (first) []'s.  Do you remember the long essay on this a
year or two ago?  [I don't ... if you have a copy, please send it
to me ... ]
-- 

	Joe Yao		hadron!jsdy at seismo.{CSS.GOV,ARPA,UUCP}



More information about the Comp.lang.c mailing list