https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58876
--- Comment #15 from Jonathan Wakely <redi at gcc dot gnu.org> --- This seems simpler and cleaner: --- a/gcc/cp/init.cc +++ b/gcc/cp/init.cc @@ -5244,6 +5244,10 @@ build_delete (location_t loc, tree otype, tree addr, tree dtor = CLASSTYPE_DESTRUCTOR (type); if (!dtor || !DECL_VINDEX (dtor)) { + const bool prev = global_dc->m_warn_system_headers; + // Don't suppress this warning in system headers. + global_dc->m_warn_system_headers = true; + if (CLASSTYPE_PURE_VIRTUALS (type)) warning_at (loc, OPT_Wdelete_non_virtual_dtor, "deleting object of abstract class type %qT" @@ -5254,6 +5258,7 @@ build_delete (location_t loc, tree otype, tree addr, "deleting object of polymorphic class type %qT" " which has non-virtual destructor" " might cause undefined behavior", type); + global_dc->m_warn_system_headers = prev; } } } This warning is always useful, even in system headers. But Jason is working on an ever better solution, so that we can stop using the system_header pragma in libstdc++ headers.