NULL vs 0 vs 0L bikeshed time

Erik Trulsson ertr1013 at student.uu.se
Mon Mar 1 09:11:13 PST 2004


On Mon, Mar 01, 2004 at 05:42:28PM +0100, Dag-Erling Smørgrav wrote:
> Mark Murray <mark at grondar.org> writes:
> > I'd like to commit the following patch. It makes sure that for C
> > and the kernel, NULL is a ((void *)0)
> 
> This is not correct, because it makes NULL unusable for function
> pointers; you can assign 0 to a function pointer, but not (void *)0.

If it is valid to assign 0 to a function pointer then it is valid to
assign ((void*)0).  They are both null pointer constants
If the compiler does not allow it then it is a compiler bug IMO.

(I am not quite sure if it is actually valid to assign a null pointer
constant to a function pointer, but I think it is, and if it is valid
then any null pointer constant shall work.)


-- 
<Insert your favourite quote here.>
Erik Trulsson
ertr1013 at student.uu.se


More information about the freebsd-current mailing list