time(0L) - history of a misconception (was Re: SCO password generator)
Len Reed
lbr at holos0.uucp
Sat May 25 01:13:50 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". 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).
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.)
You're certainly right that a NULL that produced a virtual memory fault
upon any use would be better than a virtual zero address. But it's not
the "compiler people" who would have to agree to this. Far too much
existing code would be broken by a move to this, I'm afraid.
--
Len Reed
Holos Software, Inc.
Voice: (404) 496-1358
UUCP: ...!gatech!holos0!lbr
More information about the Comp.unix.sysv386
mailing list