PCC, lint bug

Stanley Friesen friesen at psivax.UUCP
Wed Sep 4 03:08:29 AEST 1985


In article <1152 at brl-tgr.ARPA> root%bostonu.csnet at 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 at rand-unix.arpa



More information about the Comp.unix.wizards mailing list