Re: [gtkmm] Class Glib::ValueBase (in File glib/glibmm/value.h) has non-virtu al destructor



On Fri, 2002-08-23 at 12:57, Hopfes, Harald wrote:
> Hi!
> 
> But the class mentioned in the subject has several child-classes:
> ValueBase_Boxed
> ValueBase_Object
> ValueBase_Enum
> ValueBase_Flags
> ValueBase_String
> and these classes again have child classes:
> Value< Glib::RefPtr<T> >
> Value<std::string>
> ...
> 
> It would assume that this is not correct.
> (I am actually having some strange Bug, that could come from this.)
> (e.g. Bug refered in http://bugzilla.gnome.org/show_bug.cgi?id=78578 could
> orignate from the same problem???)
> 
> I hade sometimes the experience that a thing like that could make the GNU
> compiler creating a corrupted vtable. (Actually it should just not call the
> dtor of the parent class, but who knows?)

Actually, the dtor of the parent class is always called, whether virtual
or not, if you are destructing an actual derived class, e.g.
ValueBase_Boxed.

virtual dtor is used when destroying an object like ValueBase_Boxed*
when it is referenced as a ValueBased*.  For example:

ValueBase* ptr = new ValueBase_Boxed();
delete ptr;   // without virtual dtor, only calls ValueBase::~ValueBase().
              // with virtual dtor, calls ValueBase_Boxed::~ValueBase_Boxed()


But it still seems like a bug.

Regards,
Carl




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]