time(0L) - history of a misconception (was Re: SCO password generator)

Jim Balter jim at segue.segue.com
Fri May 24 08:38:38 AEST 1991


In article <1991May22.130713.25852 at sco.COM> david at sco.COM (David Fiander) writes:
>There exist architectures on which the NULL pointer is different from
>"all bits 0".

This isn't relevant if using ANSI prototypes, since any form of zero is
implicitly converted to the appropriate null pointer, no matter how it is
represented.  If you aren't using ANSI prototypes, then you should manually
cast everything into the proper type, and run lint religiously.  Hopefully,
some day, we will only concerned with the first case.

>In fact, if you can get the compiler people to agree to
>it, the best value for the NULL pointer is something that is an invalid
>virtual memory address, because then, when somebody tries to dereference
>it, you get a core dump (note that 0 might be a valid address which would
>never be referred to by the user, for example: the address of the C
>startup code).

This doesn't require a non-zero representation of NULL, since page 0 of
the virtual address space can usually be made inaccessible.  Most UNIX systems
don't do it because there are too many bad UNIX programs written by too many
bad UNIX programmers, and any desire to do the "right" thing is overridden
by the market demand to allow programs that dereference NULL to continue to
"work".



More information about the Comp.lang.c mailing list