Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!brutus.cs.uiuc.edu!jarthur!elroy.jpl.nasa.gov!ucla-cs!das From: das@lanai.cs.ucla.edu (David Smallberg) Newsgroups: comp.lang.c Subject: Re: references to dereferenced null pointers Message-ID: <33141@shemp.CS.UCLA.EDU> Date: 17 Mar 90 01:47:08 GMT References: <51083@microsoft.UUCP> <25EB8EE8.8462@paris.ics.uci.edu> <1990Mar12.175613.12082@utzoo.uucp> <1623@argus.UUCP> <1990Mar14.164539.23685@utzoo.uucp> <16179@haddock.ima.isc.com> Sender: news@CS.UCLA.EDU Reply-To: das@lanai.UUCP (David Smallberg) Organization: UCLA Computer Science Department Lines: 20 In article <1990Mar14.164539.23685@utzoo.uucp> henry@utzoo.uucp (Henry Spencer) writes: >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. I've seen "the constant 0" misinterpreted in this way: thing *array[100]; /* clear array to NULLs */ <-- WRONG (void) memset(array,0,sizeof(array)); or (void) memset(array,NULL,sizeof(array)); The offender believes that since he's using the constant 0, the compiler will use the appropriate bit pattern for a NULL pointer, even if that's not all-zero-bits. -- David Smallberg, das@cs.ucla.edu, ...!{uunet,ucbvax,rutgers}!cs.ucla.edu!das