|
Boost : |
Subject: Re: [boost] [exception] warning about non-virtual destructor - resolution?
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2012-04-16 15:12:21
On Mon, Apr 16, 2012 at 9:14 AM, Hite, Christopher <
Christopher.Hite_at_[hidden]> wrote:
> Mathias Gaunard wrote:
> > On 16/04/12 15:29, Daniel James wrote:
> > In certain cases, the potential problem of a non-virtual destructor
> > generates a warning when the declaration of the destructor is
> > encountered. In other cases, the warning gets generated when a call to
> > the destructor is made. In yet other cases, only if the call to the
> > destructor is made through the delete operator.
> I think they've gotten better at this.
>
> You're really hard pressed to come up with situations where you would care
> about an extra virtual table entry and an extra indirection while deleting.
>
The reason to care isn't performance. I tend to take the virtual keyword
seriously when I read code: it is an invitation to call the function
through a base type pointer. In this case it would be a bug if the
destructor is ever called virtually. You'll know your compiler is wrong
when it tries to "protect" you from conscious and correct design decisions.
That said, the warning is annoying and I want it gone. I have not been able
to reproduce it.
Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk