Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!gem.mps.ohio-state.edu!ginosko!brutus.cs.uiuc.edu!apple!sun-barr!texsun!texbell!vector!attctc!kcdev!pars!cpsolv!rhg From: rhg@cpsolv.UUCP (Richard H. Gumpertz) Newsgroups: comp.lang.c Subject: Re: effect of free() Message-ID: <172@cpsolv.UUCP> Date: 8 Sep 89 15:23:20 GMT References: <319@cubmol.BIO.COLUMBIA.EDU> <3756@buengc.BU.EDU> <1989Aug17.005548.745@twwells.com> <16022@vail.ICO.ISC.COM> <248@seti.inria.fr> <246@ssp1.idca.tds.philips.nl> Reply-To: rhg@cpsolv.uucp (Richard H. Gumpertz) Organization: Computer Problem Solving, Leawood, Kansas Lines: 18 Re: loading the value of the pointer into a register to test it may cause a fault ... Seems to me that a compiler should avoid loading the pointer into a register if that might cause a fault! The pointer comparison context is fundamentally different from the pointer indirection context; the former should be able to work with invalid pointer values (at least when the comparison is to NULL) while the latter may fault. Surely the compiler implementor can find a code sequence that avoids faults when comparing invalid pointers to NULL! (For example, load the pointer into an appropriately sized data register instead of an address register.) By the way, the standard (3.3.9) lists all sorts of constraints on pointer comparison of the form "operand is a pointer to an object" but then leaves off "to an object" in the clause mentioning comparisons to NULL. That may be significant (although they may have only been allowing the pointer to be NULL as opposed to invalid).