time(0L) - history of a misconception

Doug Gwyn gwyn at smoke.brl.mil
Sat May 25 13:01:20 AEST 1991


In article <1991May24.151350.22705 at holos0.uucp> lbr at holos0.uucp (Len Reed) writes:
>Under what architecture is a NULL pointer not "all bits 0"?  The problems,
>as many have said, result when a pointer has fewer or more bits than
>an integer (or a long).  NULL pointers *are* all zeros, though, since
>casting zero to a pointer must yield a null pointer.  (Maybe there's
>a loophole here in ANSI that says that (void *)0 is a null pointer but
>the compiler could implement that casted zero as somthing other than
>a pattern of zeros.  Not likely in the real world.)

Please don't post assertions like these when you're not sure of your facts;
it adds confusion, not enlightenment.  Innumerable times in the past in this
newsgroup (and in comp.std.c), correct discussions of this issue have been
posted, and I'm pretty sure it's in the FAQ list.

In fact, in both theory and the real world, null pointers need not be
represented as all zero bit patterns, nor need pointers have the same size
as some integral type, nor need all pointers have the same size.  There
are several C implementations where one or more of those assumptions would
be in error.  Furthermore, these characteristics pose no problem for a
programmer who avoids making such assumptions.



More information about the Comp.lang.c mailing list