From owner-cvs-gnu Fri Sep 19 11:19:14 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id LAA28533 for cvs-gnu-outgoing; Fri, 19 Sep 1997 11:19:14 -0700 (PDT) Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.19]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id LAA28525; Fri, 19 Sep 1997 11:19:09 -0700 (PDT) Received: (from bde@localhost) by godzilla.zeta.org.au (8.8.5/8.6.9) id EAA25970; Sat, 20 Sep 1997 04:10:45 +1000 Date: Sat, 20 Sep 1997 04:10:45 +1000 From: Bruce Evans Message-Id: <199709191810.EAA25970@godzilla.zeta.org.au> To: bde@zeta.org.au, pst@shockwave.com Subject: Re: cvs commit: src/gnu/usr.bin/as/config atof-ieee.c src/gnu/usr.bin/ld/rtld rtld.c src/gnu/usr.bin/man/man man.c Cc: cvs-all@FreeBSD.ORG, cvs-committers@FreeBSD.ORG, cvs-gnu@FreeBSD.ORG, jonny@coppe.ufrj.br, phk@FreeBSD.ORG Sender: owner-cvs-gnu@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk >> void foo(bar) void *bar; { ... } >> ... >> foo(NULL); /* no prototype in scope */ >> >> `lint -p' should warn that the arg is inconsistent, but can't do so if >> NULL is ((void *)0). > >Could you please explain that more clearly? I see a perfectly good implied >prototype in scope, and the fact of the matter is that I should not be forced 1. There is no prototype in scope - the function is purposely declared old- style so that it does not provide a prototype. 2. The comment is supposed to make this clearer. >to typecast NULL into a particular pointer type, ever. Null is well defined >as a "pointer of some type, with a value of 0" To me, #define NULL (void *)0 >is the ultimate protection against the misuse of NULL. No, NULL is macro which expands to an implementation-defined null pointer constant. A null pointer constant is either an integral constant expression with value 0, or such an expression cast to `void *'. Portable programs must not assume a particular implementation. Even if NULL is a pointer (necessarily of type `void *'), it must be cast to the correct type in function calls. The cast is best done by putting a prototype in scope. Example: void foo(); ... foo((void *)0); /* no prototype in scope */ ... void foo(bar) int *bar; { ... } `lint -p' should warn that the arg is inconsistent, but the FreeBSD version doesn't. It warns for the equivalent `foo((char *)0)'. Bruce