🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #1910

Re: Why not op delete(void* v&,size_t);?

#1910
From: Todd Blanchard
Date: Tue, 05 Sep 1995 05:09
57 lines
2881 bytes
Steve Clamage (clamage@Eng.Sun.COM) wrote:
: In article 95Sep1110410@physics12.Berkeley.EDU, tblancha@evolving.com (Todd Blanchard) writes:
: >This is common in C:
: >
: >#define free(X) { free(X); X=0; }
: >
: >You could do something similar in C++ as:
: >
: >void operator delete (void*& p, size_t s)
: >{
: >   ::delete p;
: >   p = 0;
: >}
: >
: >but the standard definition is:
: >void operator delete(void* p, size_t);
: >
: >Why is that?

: 1. The argument to operator delete need not be an lvalue:
: 	T* foo();
: 	...
: 	delete foo();

Possibly, but zeroing a ref to temp is still harmless.

: 2.  Believing that this approach solves the dangling pointer problem even
: in C, is naive, and leads to a false sense of security. The program might
: have any number of copies of the pointer which was deleted, and the copies
: would still dangle. You have to use a design discipline that keeps track of
: who owns the heap object and under what circumstances it is to be deleted.

This is plain insulting.  I know how to manage memory.  I continue to look
for techniques to reduce the consequences of screw-ups.

I never said it solved the dangling pointer problem.  It can help mitigate
it though.  Half a life jacket is better than no life jacket at all.  Idiotic
unix hackers that call any attempt to reduce the consequences of brain lock
"naive" and insist on leaving everything as dangerous as possible so people will
retain that heightened sense of awareness one gets living in a war zone are
clearly the naive ones.  

Designers could try telling the truth once in awhile and say something like:
"Nobody thought of it early enough and its too late to change now."
Which I suspect is more likely.

--
-----------------------------------------------------------------------
Todd Blanchard                                    tblancha@evolving.com
Evolving Systems Inc.                               VOX: (303) 689-1798
                                                    FAX: (303) 689-1399
"Never underestimate the power of stupid people in large groups."
-----------------------------------------------------------------------
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <42fp2l$lvf@citadel.evolving.com>
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
References: <MATT.95Sep1110410@physics12.Berkeley.EDU> <427l56$cd7@engnews2.Eng.Sun.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
Date: 05 Sep 95 05:09:54 GMT
Approved: fjh@cs.mu.oz.au
From: tblancha@evolving.com (Todd Blanchard)
Newsgroups: comp.std.c++
Subject: Re: Why not op delete(void* v&,size_t);?
X-Original-Date: 4 Sep 1995 20:54:45 GMT
Organization: Evolving Systems, Inc.
Message-ID: <42fp2l$lvf@citadel.evolving.com>
References: <MATT.95Sep1110410@physics12.Berkeley.EDU> <427l56$cd7@engnews2.Eng.Sun.COM>
X-Newsreader: TIN [version 1.2 PL2]