Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!cs.utexas.edu!uunet!paralogics!shaw From: shaw@paralogics.UUCP (Guy Shaw) Newsgroups: comp.lang.c Subject: Re: effect of free() Summary: Are there C development/run-time environments that will check pointers that strictly, even while running on "conventional" machines? Message-ID: <247@paralogics.UUCP> Date: 9 Sep 89 15:51:31 GMT References: <319@cubmol.BIO.COLUMBIA.EDU> <3756@buengc.BU.EDU> <19474@mimsy.UUCP> <11008@smoke.BRL.MIL> Organization: Paralogics; Santa Monica, CA Lines: 39 In article <11008@smoke.BRL.MIL>, gwyn@smoke.BRL.MIL (Doug Gwyn) writes: > In article <9278@attctc.Dallas.TX.US> chasm@attctc.Dallas.TX.US (Charles Marslett) writes: > >Why don't we just say is it lousy looking code that does this sort of thing -- > >so don't do it (even though it will work 99999 times out of 10000, or whatever > >the fraction really is. > > Good advice; since it is not necessary to rely on the nonportable > ability to continue to play with a pointer after it is free()d, > it is best to simply avoid doing so. Do any of the C development/run-time environments, such as Sabre-C, have run-time pointer checking code that is as strict as the kinds of hardware that has been discussed here recently? I know there are C interpreters or run-time environments that will check array bounds and will take care of dereferencing bad pointers, even when the usual run-time code would just keep slashing away and surprise you later, on many machines. But, are there any that can simulate the the kind of hardware that says, "don't even think about bad pointers"? I don't have any objection to coding safely, but I don't trust myself to catch every potential portability problem, by hand. I don't think lint could catch this. As a matter of fact, I can't think of a way to make some new version of lint catch this in ALL cases. Offhand, it seems that generating code to do this at run time is the only way to get that kind of enforcement. Perhaps, another cc switch. Yes, I know, that does not prove your program doesn't have bugs in unexercised parts of your program, but neither does running it on strict hardware. I don't want to buy a Unisys A-series machine (or whatever) just to run my code to make sure it is maximally portable. But if I had the option handy in software, I would use it to supplement lint. Thanks in advance. -- Guy Shaw Paralogics paralogics!shaw@uunet.uu.net or uunet!paralogics!shaw