On 5/26/05, Caleb Tennis <[EMAIL PROTECTED]> wrote:

> On Thursday 26 May 2005 02:30 am, Duncan wrote:
> > So the KDE problem... Is that what's causing all those virtual function
> > but destructor isn't virtual type warnings whenever I compile a KDE ebuild
> > with gcc4?
> 
> No, that's just shoddy C++ coding that also needs to be fixed.

Sorry to cut in like this, but I get tired of comments like this.
While this specific case might very well represent "shoddy" coding,
there are perfectly good reasons to have non-virtual destructors in
classes designed to be base classes.

One common case is when COM-style reference counting is used. In such
a scenario leaf classes always implement a release() member function
which deletes 'this' when the reference count goes to zero. With this
configuration there is no need for a virtual destructor since
destructor chaining always happens from a leaf class.

I hope one day GCC's warning for this will be smart enough to at least
not complain about non-public non-virtual destructors in classes that
otherwise contain virtual member functions. Then the warning will be
useful and perhaps indicate "shoddy C++ coding". :-)

// Andreas

-- 
gentoo-dev@gentoo.org mailing list

Reply via email to