Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!columbia!rutgers!ames!oliveb!sun!gorodish!guy From: guy%gorodish@Sun.COM (Guy Harris) Newsgroups: comp.unix.questions Subject: Re: Shutting lint up about malloc (missing /*NOSTRICT*/) Message-ID: <19123@sun.uucp> Date: Mon, 18-May-87 15:33:12 EDT Article-I.D.: sun.19123 Posted: Mon May 18 15:33:12 1987 Date-Received: Tue, 19-May-87 05:39:55 EDT References: <61@amanue.UUCP> <1994@a.cs.okstate.edu> Sender: news@sun.uucp Lines: 35 > Comparing a structure pointer (namely p) against NULL (sometimes declared as > ((char *)0) is probably biting you. The amount of misinformation circulating on USENET about null pointers is both awesome and depressing. ANY COMPILER THAT CAN'T PROPERLY HANDLE struct foo *p; if (p == 0) (i.e., won't compile it into a comparison of "p" with a null pointer of the proper type) IS NOT A VALID C COMPILER. ANY IMPLEMENTATION OF C THAT DEFINES NULL AS "(char *)0" IS AN INVALID C IMPLEMENTATION. Furthermore, if the implementation is illegally defining NULL as "(char *)0", casting NULL to "(struct foo *)NULL" will elicit a complaint from "lint", so that won't even fix the problem! The complaint he is getting from "lint" is NOT "illegal pointer combination", it's "possible pointer alignment problem". "lint" is NOT complaining about the comparison of "p" with NULL. It is complaining about the casting of the result of "malloc" to type "struct foo *". The reason why NOSTRICT doesn't work is that, to the best of my knowledge, it has never been implemented, not that it was dropped. As for why it was never implemented, I don't know; try asking Steve Johnson - I think he's working at the Dana Group now. Unfortunately, there's no way to silence "lint" in this case. In the S5R2 version, both the "-h" and "-p" flags turn on the check for possible alignment problems. Perhaps when ANSI C becomes a standard, "lint" will not complain about alignment problems when converting "void *" pointers.