Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ames!uhccux!munnari.oz.au!murtoa.cs.mu.oz.au!otc!metro!extro!natmlab!ditsyda!evans From: evans@ditsyda.oz (Bruce Evans) Newsgroups: comp.lang.c Subject: Re: effect of free() Message-ID: <2196@ditsyda.oz> Date: 9 Sep 89 20:13:51 GMT References: <319@cubmol.BIO.COLUMBIA.EDU> <3756@buengc.BU.EDU> <10971@smoke.BRL.MIL> <2054@munnari.oz.au> <247@ssp1.idca.tds.philips.nl> <10982@smoke.BRL.MIL> Reply-To: evans@ditsyda.oz (Bruce Evans) Organization: CSIRO DIT Sydney, Australia Lines: 18 In article <10982@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes: >In article <247@ssp1.idca.tds.philips.nl> dolf@idca.tds.PHILIPS.nl (Dolf Grunbauer) writes: >>What about the case when ptr is already in a register >>(i.e. definition of ptr: register char *ptr) ? Will there be an address trap >>right after the free as some address register now holds an invalid address ? > >No, provided that you don't try to copy the now-defunct address into some >other variable or to use it in any other way. Storing a valid address in register char *ptr; ... free(ptr); The compiler will have difficulty maintaining the register across the function call. It might have to forbid pointers in registers, or they might not fit. A loss either way. -- Bruce Evans evans@ditsyda.oz.au