Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!ico!vail!rcd From: rcd@ico.ISC.COM (Dick Dunn) Newsgroups: comp.lang.c Subject: Re: effect of free() Summary: aaaaagh! the question that wouldn't die! Message-ID: <16028@vail.ICO.ISC.COM> Date: 21 Aug 89 23:22:57 GMT References: <319@cubmol.BIO.COLUMBIA.EDU> <3756@buengc.BU.EDU> <568@augean.OZ> Organization: Interactive Systems Corp, Boulder, CO Lines: 23 In the midst of the pointer-to-freed-area stuff, idall@augean.OZ (Ian Dall) writes: > - if (ptr == 0) ... . . . > Well you should strictly do something like > > if (ptr == (char *) 0) ... Will this *never* die? How many times does it need to be said that you don't have to cast 0 to compare it with a pointer? (mutter, grumble...) In the context of free(ptr) before the test... > If that causes a trap your compiler and/or operating system is > definitely broken... No, NOT broken according to the standard. If it causes a trap, you have quite an unusual system (and I'd like to know what it is), but it's not broken. free(ptr) won't change the pointer, of course, but it is theo- retically possible for it to change the validity of testing it. (more to follow on this...) -- Dick Dunn rcd@ico.isc.com uucp: {ncar,nbires}!ico!rcd (303)449-2870 ...Are you making this up as you go along?