Subject: Re: sys/null.h
To: None <>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-userlevel
Date: 04/13/2005 12:32:51
> * What happens on I32LP64 systems?
>    fprintf(stderr, "%#p %#p\n", NULL, NULL, 1, 2, 3, 4);
>    I would expect the answer to not be "0x0 0x0".

And you'd be correct.  The code is broken; NULL needs to be cast
whenever it occurs in a context that does not provide a type (and a
varargs function call argument is such a context).

> * Why don't we always #define NULL ((void *) 0) ?

I didn't make that decision, but I support it, because it makes code
such as the above *obviously* broken instead of *quietly* broken.  I do
not think it is any favour to coders to arrange for sloppy broken code
to "work" despite it's brokenness.  (When there are other reasons for
doing whatever it is, that's different, but here, I see no reason for
adding a cast to void * except to make NULL in varargs calls "work".)

This is one of the reasons I consider NULL harmful.  I've mentioned
this on-list before, though on another list; see and for more.

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B