Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c++ Subject: Re: Curious about operator delete setting ptrs to zero... Message-ID: <546@taumet.com> Date: 8 Jan 91 17:22:55 GMT References: Organization: Taumetric Corporation, San Diego Lines: 20 warsaw@nlm.nih.gov (Barry A. Warsaw) writes: >Having been bitten lately with multiple destruction of freestore >allocated objects, I'm curious as to why operator delete does not, by >default, set the pointer whose object is being deleted to zero? Operator delete setting the pointer to zero is allowed but not required. (E&S says the value of the pointer is undefined.) Setting it to zero solves only part of the problem, however, since there may be other pointers in the program pointing to the now-deleted object. It is possible to make run-time reasonableness checks on pointers to determine whether they point to space which has been since freed (and possibly re-allocated). It is expensive (at run-time) to do so, however. This all comes under the heading of "quality of implementation". There is a place in the market for a spectrum of such checking by compilers. -- Steve Clamage, TauMetric Corp, steve@taumet.com