Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site rtp47.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!mcnc!rti-sel!rtp47!throopw From: throopw@rtp47.UUCP (Wayne Throop) Newsgroups: net.lang.c,net.unix-wizards Subject: Re: Re: PCC, lint bug Message-ID: <178@rtp47.UUCP> Date: Mon, 9-Sep-85 19:58:59 EDT Article-I.D.: rtp47.178 Posted: Mon Sep 9 19:58:59 1985 Date-Received: Wed, 11-Sep-85 07:49:43 EDT References: <1152@brl-tgr.ARPA> <81@copper.UUCP> <10287@ucbvax.ARPA> Followup-To: net.lang.c Organization: Data General, RTP, NC Lines: 49 Xref: watmath net.lang.c:6331 net.unix-wizards:14788 > I'm disgusted at the number of 'wizards' who are confused. > 'x' should best be though of as a pointer to array of two ints. > int y[2][2][2]; /* y should best be thought of as a pointer to > two dimentional array of ints ([2][2]) */ > int yp[][2][2] = y; /* is a proper pointer */ > Jeff Anton ucbvax!anton anton@BERKELEY.EDU Now wait a minuite. As near as I can tell from this fragment, Jeff is as confused as any other wizard. Since an initializer is used in the declaration int yp[][2][2] = y; yp is clearly *not* a formal. And this being the case, *yp* *is* *not* (I repeat *not*) a pointer. I assume what is meant to happen for the two above declarations is int y[2][2][2]; int (*yp)[2][2] = y; The abomination Jeff gave above declares yp to be an array of 1 array of 2 array of 2 integers, and (if the compiler doesn't choke) initializes yp[0][0][0] to be the expression (int)y. Yuck. I tried this C file on SysV lint: int x1[2][2]; int x2[][2] = x1; /* I hope lint complains here */ int (*x3)[2] = x1; /* I hope lint doesn't complain here */ And lint quite properly complained, saying: warning: illegal combination of pointer and integer: (2) operator = It is interesting that pointer/array equivalence causes such problems, when it it really so simple. The *only* (I repeat *only*) place where a declarator like "int x[]" declares x to be a pointer is in *formal* declarations. In static, external, or automatic declarations, *x* *is* *an* *array* (of compiler or loader determined size). And even in formal declarations, x "should be" *thought of* as an array. -- Note that Followup-To specifies net.lang.c -- "People who live in glass houses, shouldn't" -- Wayne Throop at Data General, RTP, NC !mcnc!rti-sel!rtp47!throopw