Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!harpo!seismo!hao!hplabs!sri-unix!edhall@rand-unix From: edhall%rand-unix@sri-unix.UUCP Newsgroups: net.unix-wizards Subject: Re: NULL vs 0 Message-ID: <16406@sri-arpa.UUCP> Date: Sat, 4-Feb-84 04:32:00 EST Article-I.D.: sri-arpa.16406 Posted: Sat Feb 4 04:32:00 1984 Date-Received: Thu, 9-Feb-84 02:40:27 EST Lines: 29 From: Ed_HallAs I believe has been pointed out here before, the constant `0' has a special interpretation when assigned or compared to a pointer. It behaves as the `null pointer' in these cases, *whatever that happens to be*. Thus, on a given computer a null pointer could have a non-zero value, and the constant `0' would be interpreted as that value in a pointer context. Of course, the place this breaks down is in procedure arguments, as C currently has no means of declaring whether a given argument to a procedure call is a pointer or not. This would then require a cast to produce the correct null-pointer value. Another solution is to have the compiler produce code which checks each pointer parameter for zero and converts it to the proper null- pointer value before it is used inside the called procedure. Compiler writers have been forced to do worse things by unusual (to C) architectures. This should work except when an actual zero is a legal (and non-null) pointer. (This, by the way, would be possible on a split I/D PDP-11 if the loader didn't start the data segment at an address of 2; I'm certain loaders for other machines could be hacked if necessary to make zero unique.) -Ed Hall Rand Corporation Santa Monica, CA edhall@rand-unix (ARPA decvax!randvax!edhall (UUCP)