Xref: utzoo comp.lang.c++:6809 comp.std.c:2611 Newsgroups: comp.lang.c++,comp.std.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: references to dereferenced null pointers Message-ID: <1990Mar14.164539.23685@utzoo.uucp> Organization: U of Toronto Zoology References: <51083@microsoft.UUCP> <25EB8EE8.8462@paris.ics.uci.edu> <1990Mar12.175613.12082@utzoo.uucp> <1623@argus.UUCP> Date: Wed, 14 Mar 90 16:45:39 GMT In article <1623@argus.UUCP> ken@argus.UUCP (Kenneth Ng) writes: >I'm confused, is a non zero NULL pointer valid or not? I'm not asking if >it will break 90% of the programs out there that use 0 instead of NULL. >On a 370 here I'd love to define NULL as -1 because it will cause an >immediate addressing exception if it is referenced. But, I was told that >NULL is defined as always being the value zero. NULL is just a convenient way of writing the constant 0, for all practical purposes. It is *not*, by itself, a null pointer, because there is no "generic null pointer" type. NULL has to be converted to a specific pointer type to become a null pointer. That (compile-time) conversion may well change the representation in some strange way. `NULL' must remain 0 (or a close equivalent), but `(foo *)NULL' can be a different story. There is absolutely nothing wrong with having a pointer representation in which the bit pattern for a null pointer is not all zeros... except that there are a lot of old, badly-written programs which will break. Thus my earlier comment that it is valid but unwise. -- MSDOS, abbrev: Maybe SomeDay | Henry Spencer at U of Toronto Zoology an Operating System. | uunet!attcan!utzoo!henry henry@zoo.toronto.edu