Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site psivax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxn!ihnp4!qantel!hplabs!sdcrdcf!psivax!friesen From: friesen@psivax.UUCP (Stanley Friesen) Newsgroups: net.unix-wizards Subject: Re: Re: PCC, lint bug Message-ID: <703@psivax.UUCP> Date: Tue, 3-Sep-85 13:08:29 EDT Article-I.D.: psivax.703 Posted: Tue Sep 3 13:08:29 1985 Date-Received: Sun, 8-Sep-85 05:02:17 EDT References: <1152@brl-tgr.ARPA> Reply-To: friesen@psivax.UUCP (Stanley Friesen) Organization: Pacesetter Systems Inc., Sylmar, CA Lines: 29 Summary: In article <1152@brl-tgr.ARPA> root%bostonu.csnet@csnet-relay.arpa (BostonU SysMgr) writes: > > >WRONG WRONG WRONG > >THE ERROR IS ALLOWING THE DECLARATION TO PASS BOTH C AND LINT: > > int x[STUFF][THING] ; /* the name 'x' is a pointer to an int */ > int **xp = x ; /* not a pointer to a pointer */ > >I do not believe *any* reading of 'x' lets it be a pointer to a pointer. Still wrong: x is a pointer to an array of THING int's! This is *not* the same as a pointer to an int or a pointer to a pointer to an int! The difference shows up in the following: (x + 1) == &x[1] *not* &x[0][1] that is adding one to a pointer increments it by *the* *size* *of* *the* *object* pointed to - in this case sizeof(int [THING]) not sizeof(int). The correct declarations above would be: int x[STUFF][THING]; int *xp[THING] = x; -- Sarima (Stanley Friesen) UUCP: {ttidca|ihnp4|sdcrdcf|quad1|nrcvax|bellcore|logico}!psivax!friesen ARPA: ttidca!psivax!friesen@rand-unix.arpa