Gentoo Archives: gentoo-dev

From: Andreas Fredriksson <deplinenoise@×××××.com>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] Re: Re: KDE 3.4 visibility support disabled
Date: Thu, 26 May 2005 16:09:17
Message-Id: 3212b1a80505260909506ed4e1@mail.gmail.com
In Reply to: Re: [gentoo-dev] Re: Re: KDE 3.4 visibility support disabled by Caleb Tennis
1 On 5/26/05, Caleb Tennis <caleb@g.o> wrote:
2
3 > On Thursday 26 May 2005 02:30 am, Duncan wrote:
4 > > So the KDE problem... Is that what's causing all those virtual function
5 > > but destructor isn't virtual type warnings whenever I compile a KDE ebuild
6 > > with gcc4?
7 >
8 > No, that's just shoddy C++ coding that also needs to be fixed.
9
10 Sorry to cut in like this, but I get tired of comments like this.
11 While this specific case might very well represent "shoddy" coding,
12 there are perfectly good reasons to have non-virtual destructors in
13 classes designed to be base classes.
14
15 One common case is when COM-style reference counting is used. In such
16 a scenario leaf classes always implement a release() member function
17 which deletes 'this' when the reference count goes to zero. With this
18 configuration there is no need for a virtual destructor since
19 destructor chaining always happens from a leaf class.
20
21 I hope one day GCC's warning for this will be smart enough to at least
22 not complain about non-public non-virtual destructors in classes that
23 otherwise contain virtual member functions. Then the warning will be
24 useful and perhaps indicate "shoddy C++ coding". :-)
25
26 // Andreas
27
28 --
29 gentoo-dev@g.o mailing list