[gclist] A problem with reference count & type systems.

Charles Fiterman cef@geode.geodesic.com
Wed, 10 Apr 1996 07:48:22 -0500


Reference count systems are a fast sure way of calling
finalizers assuming cycles can be avoided. But there is
a problem with connecting them to type systems.

class noDestructor {
  ...
  ...
}

class hasDestructor : public noDestructor {
  ...
  ...
}

Now pointers to items of class hasDestructor must do the
reference count trick and particapate in what ever cycle
avoidence schemes are part of the system. Further any
object containing an object with a destructor itself
has a destructor. Pointers to hasDestructor objects themselves
have destructors.

Here's the catch. noDestructor *p; may point at a hasDestructor
object. If it does it must particapate in all the reference
count garbage. This is very painful and suggests the need for
another solution.