[comp.bugs.4bsd] Some [non-existent] bugs in lint

rbutterworth@watmath.waterloo.edu (Ray Butterworth) (02/26/88)

In article <238@ksr.UUCP>, benson@phantom.ksr.com (Benson Margulies) writes:
> Here are two bugs and a perhaps bug in 4.3 lint, both demonstrated by
> the following trivial source file:
> 
> bcopy(b1, b2)
> register char *b1, *b2;
> {
> *(((long *)b2)++) = *((long *)b1)++;
> }
> 
> t.c(4): illegal lhs of assignment operator
> t.c(4): illegal lhs of assignment operator
> bcopy: variable # of args.      t.c(3)  ::  llib-lc(189)
> bcopy multiply declared t.c(3)  ::  llib-lc(189)
> bcopy defined( t.c(3) ), but never used


> Bug (2): why two copies of the error message?
You got TWO error messages (from the compiler too, not only lint),
because you made the same mistake twice.

> t.c(4): illegal lhs of assignment operator
> Bug (1): that lhs is quite valid.
The "assignment operator" was not the "=".  It was the "++".
The compiler was trying to assign values to the left sides of
the "++" operators.  The "lhs"s were "(long*)b2" and "(long*)b1".

Twice you tried to use "(expression)++", where "expression" is not
an lval.  e.g. you can say "b2 = 0;" or "*(long*)b2 = 0;", depending
upon what you mean, since "b2" and "*(long*)b2" are both lvals.
But "(long*)b2 = 0;" is meaningless and illegal.

> Bug? (3): to me, it seems wrong that lint reports duplicate definitions
> against the library. At very least, there should be a /* SOMETHING */
> to suppress this.
That depends upon how the library was implemented.
If all library functions call each other only by a reserved internal
name (e.g. if memcpy() wants to call bcopy() it instead calls _bcopy())
then it wouldn't matter if a program defines a function that happens
to have the same name as a library function.

Unfortunately, the BSD C library doesn't do this.  If you define a
function with the same name as one in the library, any library
function that needs to call it will get yours instead.  That is
probably not what you wanted, and LINT is simply letting you know
about it.