Skip site navigation (1)Skip section navigation (2)
Date:      28 May 1998 17:03:38 +0200
From:      dag-erli@ifi.uio.no (Dag-Erling Coidan =?iso-8859-1?Q?Sm=F8rgrav?= )
To:        Bruce Evans <bde@zeta.org.au>
Cc:        eivind@yes.no, rnordier@nordier.com, current@FreeBSD.ORG
Subject:   Re: Replacing gcc as the system compiler
Message-ID:  <xzpra1ecu9h.fsf@gjallarhorn.ifi.uio.no>
In-Reply-To: Bruce Evans's message of "Thu, 28 May 1998 13:48:06 %2B1000"
References:  <199805280348.NAA09679@godzilla.zeta.org.au>

next in thread | previous in thread | raw e-mail | index | archive | help
Bruce Evans <bde@zeta.org.au> writes:
> > There is also what looks like a bug in handling of NULL - it doesn't
> > allow the use of ((void *)0) as NULL for function pointers.
> gcc used to have this bug too.  Apparently, the C standard can easily
> be read as not allowing conversion from (void *)0 to a function pointer.
> 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
function pointer might work better than converting ((void *)0).

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)

With the correct prototypes, it is perfectly legal and semantically
correct to write e.g.

	execl("/bin/sh", "-sh", 0);

-- 
Noone else has a .sig like this one.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?xzpra1ecu9h.fsf>