[gclist] Finalization and death notices
Charles Fiterman
cef@geodesic.com
Wed, 10 Oct 2001 08:55:37 -0500
At 02:49 PM 10/10/01 +0100, you wrote:
> | [Greg Colvin <gcolvin@us.oracle.com> wrote:]
> | C++ completely decouples allocation, construction, destruction, and
> | deallocation. You can call operator new(), constructors, destructors,
> | and operator delete() directly.
>
> That's almost, but not quite, true. The real problem is that delete
*always*
> calls the destructor. If the object has already been destructed,
you're dead.
>
>When is this not a bug in the program? Why would it have been already
>destructed? Are you thinking of a collector that runs destructors on
>objects that it reclaims, which would usually, but not always, have
>been destructed (is that really a word?) already? In that case, I can
>see a way around this:
You can call the destructor by its name class foo; has a destructor named
foo~(); So users can call destructors without freeing storage. Remember you
can also new an object inplace so this is important. Invoking the
destructor turns the Vtabl pointer to zero. I repeat my proposal to have
the Vtabl part of the block descriptor and avoid having Vtabl pointers in
objects.