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?
nathan