Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site bbncca.ARPA Path: utzoo!watmath!clyde!burl!ulysses!harpo!decvax!genrad!wjh12!bbncca!keesan From: keesan@bbncca.ARPA (Morris Keesan) Newsgroups: net.lang.c Subject: Re: New LINT gag wanted Message-ID: <616@bbncca.ARPA> Date: Fri, 9-Mar-84 11:52:25 EST Article-I.D.: bbncca.616 Posted: Fri Mar 9 11:52:25 1984 Date-Received: Sat, 10-Mar-84 13:21:21 EST References: <4054@edai.UUCP> Organization: Bolt, Beranek and Newman, Cambridge, Ma. Lines: 47 ---------------------------- ok@edai complains: > #include/* defines NULL */ > typedef long **ptr; > ptr foo; > baz(x) > ptr x; > {...} > ... baz(NULL); ... foo = NULL; ... baz(foo); ... > > Lint is perfectly happy with foo = NULL; but complains about the > "inconsistent usage" of baz's first argument. Given that K&R say > that 0 is an acceptable pointer of any type, I don't find this at > all helpful. Lint is behaving in a perfectly legitimate way here, and is being very helpful in pointing out a portability problem. We've been through all of this very recently in this newsgroup. K&R do NOT say that "0 is an acceptable pointer". What is said about 0 and pointers in the C Reference Manual (Appendix A of K&R) is: 7.7 Equality operators [p. 190] . . . A pointer to which 0 has been assigned is guaranteed not to point to any object, and will APPEAR to be equal to 0; in conventional usage, such a pointer is considered to be null. [UPPER CASE mine] [This means that 0 can act like a pointer with the == and != operators] 7.14 Assignment operators [p. 192] . . . it is guaranteed that assignment of the constant 0 to a pointer will produce a null pointer distinguishable from a pointer to any object. [end of citations from Reference Manual] What you should be doing to shut lint up is casting NULL to the right type of pointer, e.g. baz((ptr)NULL); If you don't want to do this, then you want features added to lint by which you can declare something like /* COMPATIBLE int ptr */, which would document the assumption being made, or you could define NULL as ((char *)0), and then issue an /*ALIGNOK *ptr char*/ as per your following suggestion. -- Morris M. Keesan {decvax,linus,wjh12,ima}!bbncca!keesan keesan @ BBN-UNIX.ARPA