Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!uc!shamash!bls From: bls@svl.cdc.com (brian scearce) Newsgroups: comp.lang.c Subject: Re: What C compilers have non-zero null pointers? Message-ID: <23463@shamash.cdc.com> Date: 13 Jul 90 19:01:30 GMT References: <422@minya.UUCP> Sender: news@shamash.cdc.com Lines: 35 The CDC Cyber series of computers uses not-all-0-bits for NULL. Cyber addresses are 48 bits long, with 4 bits for ring, 12 bits for segment and 32 bits for offset. If you load an address register with a number with ring == 0, you get a hardware trap. So, on our compiler, NULL is represented by ring == (ring your program is executing in), segment == 0, offset == 0. This means that you have to be quite careful in those situations where you type 0 and mean NULL and it isn't inferable from context what you mean. The only time that this makes a difference is (I think) arguments to functions (should be "non-prototyped functions", but I haven't implemented ANSI yet). So, the output from: main() { char *p = 0; printf("%x\n", (int)p); } is: b00000000000 Its still a very good compiler. Really. This small oddity isn't as bad as most people seem to think. As I've explained to a few through email, it's almost like floating point. Nobody expects 2.0 to have the same representation as 2, but we still write 2 sometimes when we mean 2.0 (like double x = 2; is OK). -- Brian Scearce \ "I tell you Wellington is a bad general, the English are (not on CDCs behalf) \ bad soldiers; we will settle the matter by lunch time." bls@u02.svl.cdc.com \ -- Napolean Bonaparte, June 18, 1815 (at Waterloo) shamash.cdc.com!u02!bls \ From _The Experts Speak_, Cerf & Navasky