From owner-freebsd-current Thu May 28 15:21:29 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id PAA10005 for freebsd-current-outgoing; Thu, 28 May 1998 15:21:29 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.15.68.22]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id PAA09982 for ; Thu, 28 May 1998 15:21:23 -0700 (PDT) (envelope-from bde@godzilla.zeta.org.au) Received: (from bde@localhost) by godzilla.zeta.org.au (8.8.7/8.8.7) id IAA06688; Fri, 29 May 1998 08:21:15 +1000 Date: Fri, 29 May 1998 08:21:15 +1000 From: Bruce Evans Message-Id: <199805282221.IAA06688@godzilla.zeta.org.au> To: bde@zeta.org.au, dag-erli@ifi.uio.no Subject: Re: Replacing gcc as the system compiler Cc: current@FreeBSD.ORG, eivind@yes.no, rnordier@nordier.com Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG >> The standard doesn't allow conversion from an object pointer to a >> function pointer, but (void *)0 is is a null pointer constant and >> null pointer constants are special. > >The C null pointer constant is 0. No cast is needed. Converting 0 to a Not quite. 0 is one of many C null pointer consants. >function pointer might work better than converting ((void *)0). Only in not-quite-C. In C, they work identically when correctly used, and break differently when incorrectly used. >The only situation in which it is advantageous to define NULL as >((void*)0) instead of just (0) is when passing NULL to a vararg >function which lacks a prototype; but you shouldn't do that anyway, >because it will break on more than just NULL (float->double conversion >for instance) This is actully the main disadvantage defining NULL as ((void *) 0) :-) - it helps broken program work. >With the correct prototypes, it is perfectly legal and semantically >correct to write e.g. > > execl("/bin/sh", "-sh", 0); Read what you wrote in the previous paragraph. execl() is varargs, so its varadic parameters must not be uncast 0s or NULLs. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message