[Bug c++/68300] Bogus -Wnon-virtual-dtor warning with protected base class constructor
trippels at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Nov 12 09:58:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68300
--- Comment #1 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
From class.c:
1629 /* Return true, iff class T has a non-virtual destructor that is
1630 accessible from outside the class heirarchy (i.e. is public, or
1631 there's a suitable friend. */
1632
1633 static bool
1634 accessible_nvdtor_p (tree t)
1635 {
1636 tree dtor = CLASSTYPE_DESTRUCTORS (t);
1637
1638 /* An implicitly declared destructor is always public. And,
1639 if it were virtual, we would have created it by now. */
1640 if (!dtor)
1641 return true;
1642
1643 if (DECL_VINDEX (dtor))
1644 return false; /* Virtual */
1645
1646 if (!TREE_PRIVATE (dtor) && !TREE_PROTECTED (dtor))
1647 return true; /* Public */
1648
1649 if (CLASSTYPE_FRIEND_CLASSES (t)
1650 || DECL_FRIENDLIST (TYPE_MAIN_DECL (t)))
1651 return true; /* Has friends */
1652
1653 return false;
1654 }
Removing the friends check would fix the issue.
Thoughts?
More information about the Gcc-bugs
mailing list