This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++] Weffc++/Wnon-virtual-dtor confusion

On 2014.04.04 at 18:04 +0100, Nathan Sidwell wrote:
> On 04/04/14 17:54, Markus Trippelsdorf wrote:
> > markus@x4 tmp % g++ -Wnon-virtual-dtor -std=c++11 -c test.ii
> > test.ii: In instantiation of âclass A<>â:
> > test.ii:12:16:   required from here
> > test.ii:9:26: warning: base class âclass opt_storage<0>â has accessible non-virtual destructor [-Wnon-virtual-dtor]
> >   template <int = 0> class A : Option, opt_storage<0>
> ah, you've hit on the one case I was unsure about -- IMHO Scott's rule about 
> bases is incomplete.  The rule should be for publicly accessible bases only -- 
> opt_storage is private.
> The aim of the rule is to make sure that random code doing:
>    A_Base_type *ptr = ptr_to_derived; // implicit base cast
>    ...
>    delete ptr;
> behaved as one might expect and invoke the final polymorphic dtor.  Such an 
> implicit cast to a private base can't happen outside of the class.  Inside the 
> class one's expected to know what one's doing.
> I'm fine with adding a TREE_PUBLIC (base_binfo) check into the loop in c_b_a_m. 
>   Would that work for you?

Yes. Thanks.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]