Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!zaphod.mps.ohio-state.edu!wuarchive!uunet!zephyr.ens.tek.com!uw-beaver!milton!sumax!polari!rwing!seaeast!sunbrk!Usenet From: Steve.Summit@sunbrk.FidoNet.Org (Steve Summit) Newsgroups: comp.unix.sysv386 Subject: Re: time(0L) - history of a misconception (was Re: SCO password generat Message-ID: <675518012.28@sunbrk.FidoNet> Date: 25 May 91 05:57:39 GMT Sender: Usenet@sunbrk.FidoNet.Org Lines: 61 Reply-To: scs@adam.mit.edu In article <1991May24.151350.22705@holos0.uucp> lbr@holos0.uucp (Len Reed) writes: >Under what architecture is a NULL pointer not "all bits 0"? >... >(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.) It's not at all unlikely. For those of you who have no access to or interest in comp.lang.c, here are two relevant answers from its frequently-asked questions list: 13. Given all the confusion surrounding null pointers, wouldn't it be easier simply to require them to be represented internally by zeroes? A: If for no other reason, doing so would be ill-advised because it would unnecessarily constrain implementations which would otherwise naturally represent null pointers by special, nonzero bit patterns, particularly when those values would trigger automatic hardware traps for invalid accesses. Besides, what would this requirement really accomplish? Proper understanding of null pointers does not require knowledge of the internal representation, whether zero or nonzero. Assuming that null pointers are internally zero does not make any code easier to write (except for a certain ill-advised usage of calloc; see question 52). Known-zero internal pointers would not obviate casts in function calls, because the _size_ of the pointer might still be different from that of an int. 14. Seriously, have any actual machines really used nonzero null pointers? A: "Certain Prime computers use a value different from all- bits-0 to encode the null pointer. Also, some large Honeywell-Bull machines use the bit pattern 06000 to encode the null pointer." -- Portable C, by H. Rabinowitz and Chaim Schaap, Prentice-Hall, 1990, page 147. The "certain Prime computers" were the segmented 50 series, which used segment 07777, offset 0 for the null pointer, at least for PL/I. Later models used segment 0, offset 0 for null pointers in C, necessitating new instructions such as TCNP (Test C Null Pointer), evidently as a sop to all the extant poorly-written C code which made incorrect assumptions. The Symbolics Lisp Machine, a tagged architecture, does not even have conventional numeric pointers; it uses the pair (basically a nonexistent handle) as a C null pointer. Steve Summit scs@adam.mit.edu * Origin: Seaeast - Fidonet<->Usenet Gateway - sunbrk (1:343/15.0)