[mythtv] [mythtv-commits] Ticket #1992: Warning fixes

Martin Ebourne lists at ebourne.me.uk
Tue Jun 27 07:55:18 UTC 2006


On Mon, 26 Jun 2006 17:59:46 -0400, Daniel Kristjansson wrote:
> On Mon, 2006-06-26 at 22:40 +0100, Stuart Auchterlonie wrote:
>> On Mon, Jun 26, 2006 at 06:01:35PM -0000, MythTV wrote:
>> > #1992: Warning fixes
>> I'd vote for fixing the destructors. Here's some info from those who 
>> deal in reliable C++ coding
>> http://www.codingstandard.com/HICPPCM/Section_3.3_Class_Inheritance.html
>> and in particular
>> http://www.codingstandard.com/HICPPCM/Rule_3.3.2.html
> 
> The classes should never be deleted via pointers to these interfaces;
> doing so would be wrong on so many levels that it isn't even funny.

Unfortunately not adding the virtual keyword won't help in this
circumstance.

I suggest you make the destructors protected instead, then if this ever
did occur the compiler will error.

On the warning front, it would be a shame to disable the warning. I've
seen it catch several bugs so it can be valuable. Unfortunately g++ still
warns even if the destructor is protected. Therefore I would also vote for
adding the virtual keyword to silence the warning. Why? The warning only
occurs if you already have one virtual function so to add another one has
no per object cost either in code or memory footprint. Making the
destructor protected not only documents but also enforces the usage you
are after, so no chance of confusion arising.

I'll make a patch if you like, though I'm off out to work rsn so I can
only look at it later.

Cheers,

Martin.



More information about the mythtv-dev mailing list