Re: NULL vs 0 vs 0L bikeshed time

From: Erik Trulsson <ertr1013_at_student.uu.se>
Date: Mon, 1 Mar 2004 18:11:09 +0100
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
Received on Mon Mar 01 2004 - 08:11:13 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:45 UTC