Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!philmtl!ray From: ray@philmtl.philips.ca (Raymond Dunn) Newsgroups: comp.std.c Subject: Re: references to dereferenced null pointers Message-ID: <1136@philmtl.philips.ca> Date: 15 Mar 90 20:47:58 GMT References: <51083@microsoft.UUCP> <25EB8EE8.8462@paris.ics.uci.edu> <1990Mar12.175613.12082@utzoo.uucp> <1623@argus.UUCP> <12347@smoke.BRL.MIL> Organization: Philips Electronics Ltd. Product Group PC. Montreal. Lines: 27 >In article <1623@argus.UUCP> ken@argus.UUCP (Kenneth Ng) writes: >>But, I was told that NULL is defined as always being the value zero. All the things that have been said about NULL and 0 and the *internal* hidden actual value perhaps being different are of course true. Perhaps Kenneth was actually looking for a simpler answer though. In any program, you are free to use *any* value you like to represent *your* value of the illegal pointer. So long as you don't define NULL to be this, and so long as you don't pass it to library routines and expect it to be equivalent to passing NULL, or expect library routines to return that value, you will have no problems. As an example you could define: #define NOPTR(type) ((type *)-1) and use for example NOPTR(char) within your own code with the restrictions stated. It is still of course legal to pass such a value to standard routines, but if they process NULL gently, they probably wont process your NOPTR gently, but will indeed generate an exception. -- Ray Dunn. | UUCP: ray@philmtl.philips.ca Philips Electronics Ltd. | ..!{uunet|philapd|philabs}!philmtl!ray 600 Dr Frederik Philips Blvd | TEL : (514) 744-8200 Ext : 2347 (Phonemail) St Laurent. Quebec. H4M 2S9 | FAX : (514) 744-6455 TLX : 05-824090