PCC, lint bug

Guy Harris guy at sun.uucp
Tue Sep 10 17:31:51 AEST 1985


> >Does anybody else think that the array/pointer semi-equivalence is probably
> >one of the major causes of errors in C coding?
> 
> I always thought the array/pointer semi-equivalence was one of the major
> causes of easier to {read,understand} coding.

You missed the point.  The array/pointer semi-equivalence seems to be one of
the major causes of *incorrect* code, as well.  It's not a question of how
readable the code is once it's written, it's a question of whether it'll get
written correctly in the first place.  Every so often, somebody asks why

file1.c:

extern int *foo;

file2.c:

int foo[42];

doesn't work.  The person asking the question obviously doesn't realize that
just because you can say "foo[13]" in either case doesn't mean that the two
declarations mean the same thing.  Another common question is "why doesn't
this work?":

	struct frobozz *foo;

	get_frobozz_value(foo);

which code proceeds to smash some arbitrary location pointed to by the
uninitialized pointer "foo".  I suspect this assumption that a pointer to a
structure, absent a structure for it to point to, is just as good as a
structure is fallout from pointer/array confusion.

	Guy Harris



More information about the Comp.unix.wizards mailing list