Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!uakari.primate.wisc.edu!aplcen!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: effect of free() Message-ID: <10984@smoke.BRL.MIL> Date: 9 Sep 89 00:45:29 GMT References: <319@cubmol.BIO.COLUMBIA.EDU> <3756@buengc.BU.EDU> <247@ssp1.idca.tds.philips.nl> <2059@munnari.oz.au> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 34 In article <2059@munnari.oz.au> ok@cs.mu.oz.au (Richard O'Keefe) writes: >1. there are machines on which it is _possible_ to foul up like this and > still be legal. But it is _advantageous_ on those machines? That is, > are there code sequences which > (a) can handle ptr1==ptr2 where ptr1 or ptr2 is NULL and NULL > corresponds to an invalid address NULL should NOT be thought of as corresponding to ANY address, valid or otherwise. I've mentioned twice now in recent weeks how an implementor can always implement null pointers in any environment where the rest of C is implementable. In my suggestion, a null pointer was always actually a valid external (run-time library) object address; however in the general case it is up to the implementor's ingenuity just how he represents and operates with null pointers. > (b) can NOT handle ptr1==ptr2 where one of them used to be a valid > address but isn't just at the moment Yes, that's exactly what we've been talking about for over a week now. > (c) are faster or more compact than sequences which do not trap > in this case? Yes, in a trapping architecture, all pointer comparisons (for example) would have to perform additional operations, assuming it were even possible which it may not be, in the generated code in order to avoid such a trap. >2. Is it too late to put this requirement in the standard? Was it > _really_ intended that this case should be allowed to trap? I believe it was intentional. I know that members of X3J11 would occasionally mention such architectures, and even more frequently 80*86 segmentation schemes, during discussions about pointer operations.