lint vs varargs

Karl Heuer karl at haddock.ima.isc.com
Sat Oct 28 04:39:50 AEST 1989


In article <453 at bdrc.UUCP> jcl at bdrc.UUCP (John C. Lusth) writes:
>I have a lint question. Why does [SunOS] lint complain about varargs stuff?
>18:		va_start(ap);
>19:		format = va_arg(ap, char *);
>[without -c:]
>    test.c(19): warning: possible pointer alignment problem
>[with -c, the above and two more:]
>    test.c(18): warning: illegal pointer combination
>    test.c(19): warning: illegal pointer combination
>[After macro expansion, line 18 contains a cast from (int *) to (char *);
>shouldn't this always be legal?]

The problem here is that BSD-based lint, invoked with the -c option, believes
that *any* pointer cast is the moral equivalent of an uncasted assignment to a
non-matching pointer object.  If you can't live with it, don't use -c.

>On line 19, we get a cast of a char * to a char **. No guarantee that
>char ** is as wide as char *, so I guess the complaint, while annoying,
>is valid.

That's essentially correct (and the same problem occurs in USG-based lint).
This warning, and the corresponding one on malloc() calls, could be silenced
by a smarter implementation of lint and/or the header files.  I don't
recommend going to great lengths to fake it out, though.  Instead, I suggest
you report it to your vendor as a lint bug (which it is), and maybe it will
actually be fixed someday.

Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint



More information about the Comp.lang.c mailing list