Re: [sigc] sigc::trackable::~trackable() is not virtual



On Thursday 26 October 2006 17:19, stephan beal wrote:
> You're relying on UNDEFINED BEHAVIOUR when you
> subclass a type which doesn't have a virtual dtor.

Wait, that statement as it stands is not true. You invoke UB if you delete an 
object through a pointer to base if said base doesn't have a virtual dtor. 
IOW, the rule is to use a virtual dtor in the baseclass if you plan to 
polymorphically delete objects through a pointer to the baseclass. 

Now, another rule say that therefore you should either use a public, virtual 
ctor or a protected, non-virtual one, which is the second solution to the 
problem.

However, polymorphic delete is not the case the designers envisioned for 
sigc::trackable. Deriving from sigc::trackable is rather an implementation 
artifact of sigc, making syntax simpler because you can retrieve the helper 
for tracking connections by simply converting an object to its 
sigc::trackable baseclass. I'm not sure this really requires that the dtor be 
public, have you tried making it protected?

Uli

**************************************************************************************
           Visit our website at <http://www.satorlaser.de/>
**************************************************************************************

Diese E-Mail und jede mit dieser E-Mail versandte Datei ist vertraulich und ausschließlich für die Nutzung durch den vorgesehenen Empfänger bestimmt. Sollten Sie nicht der vorgesehene Empfänger dieser E-Mail sein, informieren Sie bitte den Absender.  Jeder unbefugte Zugriff oder unbefugte Weiterleitung, die Fertigung einer Kopie oder sonstige in diesem Zusammenhang stehende Handlung ist untersagt.


This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error, please be so kind to inform the sender. Any other unauthorised access, unauthorised forwarding, copying or other action in this connection at all, is prohibited.
**************************************************************************************




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