[ub] Non-virtual destructor call
Andrzej Krzemienski
akrzemi1 at gmail.com
Fri Dec 13 15:28:04 CET 2013
2013/12/13 Sebastian Redl <sebastian.redl at getdesigned.at>
> On 2013-12-13 13:56, Andrzej Krzemienski wrote:
> >
> > There is no harm, except that this is defined as UB. Could the rule be
> > relaxed to say that if the derived type is layout-compatible with the
> > base class and its destructor is implicitly declared or explicitly
> > defaulted, the behaviur is well defined?
>
> This would turn a rather simple rule...
Yes, I am proposing a more complex rule.
> You're not getting rid of a category of undefined behavior.
Correct. And that is not my goal.
> This is fragile.
Now it is all UB. Is it not fragile already?
> It's hard to teach.
>
I do not expect that this thing I am proposing would be taught. What you
would teach people doesn't change: use virtual or protected destructors in
base classes. This thing would be only exploited by programmers that feel
they know what they are doing -- at their own risk.
> the simpler rule is just better by virtue of being simpler.
>
True.
Regards,
&rzej
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.open-std.org/pipermail/ub/attachments/20131213/be3a4c9a/attachment.html
More information about the ub
mailing list