Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: effect of free() Message-ID: <10804@smoke.BRL.MIL> Date: 23 Aug 89 15:51:58 GMT References: <319@cubmol.BIO.COLUMBIA.EDU> <3756@buengc.BU.EDU> <320@cubmol.BIO.COLUMBIA.EDU> <3777@buengc.BU.EDU> <1989Aug17.005548.745@twwells.com> <568@augean.OZ> <14343@haddock.ima.isc.com> <572@augean.OZ> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 14 In article <572@augean.OZ> idall@augean.OZ (Ian Dall) writes: >In article <14343@haddock.ima.isc.com> karl@haddock.ima.isc.com (Karl Heuer) writes: >>The issue is not whether the value of ptr has changed. Some architectures >>distinguish between arithmetic registers and address registers, and refuse to >>allow arbitrary garbage to be loaded into an address register. >"free" or ANY function cannot change it's argument. "free" should not load >anything into "the special address register" (let alone "arbitrary garbage"). No, Karl knows what he's talking about. A formerly valid pointer value can become invalid as a side-effect of free()'s operation. The machine could barf if you continue to access the now-invalid pointer value (NOT just what it points at, but the pointer itself). There are admittedly not many architectures like this in common use, but if you're striving for maximum portability you might as well be aware of the possibility.