C++ Logo

sg12

Advanced search

Re: [ub] Non-virtual destructor call

From: Andrzej Krzemienski <akrzemi1_at_[hidden]>
Date: Fri, 13 Dec 2013 16:28:50 +0100
2013/12/13 Ville Voutilainen <ville.voutilainen_at_[hidden]>

>
> Why don't you do
> std::function<void(T)>*fun = new std::function<void(T)>(Callback{});
> delete fun;
> instead? Apply auto* where necessary.
>

Well, it is not a real-life use. I do not have to solve this problem in any
of my projects. I had a hypothesis that "using veneers is safe", i.e. If I
derive from a type that does not have virtual functions but I do not add
any changes to the layout, it is a safe thing to do. It turns out that
5.3.5/3 makes it unsafe, but for no good reason.

Well, having rules simpler has merit, but it also prevents certain styles
of programming.

Regards,
&rzej

Received on 2013-12-13 16:28:51