Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!harvard!seismo!vrdxhq!rlgvax!hadron!jsdy From: jsdy@hadron.UUCP (Joseph S. D. Yao) Newsgroups: net.lang.c Subject: Re: Followup to Very Tough C Riddle Message-ID: <396@hadron.UUCP> Date: Thu, 8-May-86 09:29:43 EDT Article-I.D.: hadron.396 Posted: Thu May 8 09:29:43 1986 Date-Received: Sat, 24-May-86 04:27:52 EDT References: <140@delftcc.UUCP> Reply-To: jsdy@hadron.UUCP (Joseph S. D. Yao) Organization: Hadron, Inc., Fairfax, VA Lines: 33 Summary: AARRGGHH!!! int x[][] may be int (*x)[]; but that's illegal. AARRGGHHHHHHHHHHH!!!!! In article <140@delftcc.UUCP> sam@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@seismo.{CSS.GOV,ARPA,UUCP}