effect of free()

Raymond Dunn ray at philmtl.philips.ca
Sat Sep 9 07:07:46 AEST 1989


In article <10971 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn) writes:
>
>No, Martin tried to explain why if(ptr==0) could fail after the free().
>There aren't many common architectures where this would be a problem,
>but it can happen.

Perhaps it _can_ happen, but _would_ it.

Various posters have alluded to the use of ptr being a possible problem after
free(ptr).  On reflection, I don't believe any useful architecture could have
this restriction.  If the very fact of having a non-valid address in an address
register caused a violation, is it possible to implement free?

Is anyone aware of a real example of such a problem architecture, current or
historical?

On the assumption that such an architecture does exist however, wouldn't it
be trivial for its 'C' compiler to ensure that such an expression doesn't
cause a problem, by, for example, doing the test using data registers rather
than address registers (even though verbose code just might be necessary to
achieve that)?

Wouldn't the 'C' compiler be *expected* to do that?
-- 
Ray Dunn.                    | UUCP: ..!uunet!philmtl!ray
Philips Electronics Ltd.     | TEL : (514) 744-8200  Ext: 2347
600 Dr Frederik Philips Blvd | FAX : (514) 744-6455
St Laurent. Quebec.  H4M 2S9 | TLX : 05-824090



More information about the Comp.lang.c mailing list