Repository: mesonbuild/meson

Issue:
-Wnon-virtual-dtor is a dumb option, don't use it
The default warnings for C++ (and Obj-C++) appear to include `-Wnon-virtual-dtor`. This is a very strange choice. That warning is pretty much broken by design, and doesn't warn about the right thing anyway. Why is it enabled by default?

https://github.com/mesonbuild/meson/blob/master/mesonbuild/compilers/cpp.py#L359


I added `-Wdelete-non-virtual-dtor` to GCC in [2011](https://gcc.gnu.org/g:014ab419efc12a59efebd2720d79e1c055675c85), copying it from Clang which has had it for even longer. That warns when you try to `delete` a polymorphic object with a non-virtual destructor, which is the real problem case that matters. Simply *having* a non-virtual dtor is not  bug (and GCC has numerous false positives where it warns even if the dtor is protected, or deleted, or otherwise unable to lead to the problems the warning tries to prevent).

The `-Wdelete-non-virtual-dtor` has no false positives, it only warns about code that actually has a problem, not about classes that might have a potential problem.



Discussion:

Resolving patch:
diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py
--- a/mesonbuild/compilers/cpp.py
+++ b/mesonbuild/compilers/cpp.py
@@ -190,7 +190,7 @@ def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_
         CPPCompiler.__init__(self, ccache, exelist, version, for_machine, is_cross,
                              info, exe_wrapper, linker=linker, full_version=full_version)
         ClangCompiler.__init__(self, defines)
-        default_warn_args = ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor']
+        default_warn_args = ['-Wall', '-Winvalid-pch']
         self.warn_args = {'0': [],
                           '1': default_warn_args,
                           '2': default_warn_args + ['-Wextra'],
@@ -310,7 +310,7 @@ def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_
         CPPCompiler.__init__(self, ccache, exelist, version, for_machine, is_cross,
                              info, exe_wrapper, linker=linker, full_version=full_version)
         ArmclangCompiler.__init__(self)
-        default_warn_args = ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor']
+        default_warn_args = ['-Wall', '-Winvalid-pch']
         self.warn_args = {'0': [],
                           '1': default_warn_args,
                           '2': default_warn_args + ['-Wextra'],
@@ -356,7 +356,7 @@ def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_
         CPPCompiler.__init__(self, ccache, exelist, version, for_machine, is_cross,
                              info, exe_wrapper, linker=linker, full_version=full_version)
         GnuCompiler.__init__(self, defines)
-        default_warn_args = ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor']
+        default_warn_args = ['-Wall', '-Winvalid-pch']
         self.warn_args = {'0': [],
                           '1': default_warn_args,
                           '2': default_warn_args + ['-Wextra'],
@@ -536,7 +536,7 @@ def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_
         IntelGnuLikeCompiler.__init__(self)
         self.lang_header = 'c++-header'
         default_warn_args = ['-Wall', '-w3', '-diag-disable:remark',
-                             '-Wpch-messages', '-Wnon-virtual-dtor']
+                             '-Wpch-messages']
         self.warn_args = {'0': [],
                           '1': default_warn_args,
                           '2': default_warn_args + ['-Wextra'],
diff --git a/mesonbuild/compilers/objcpp.py b/mesonbuild/compilers/objcpp.py
--- a/mesonbuild/compilers/objcpp.py
+++ b/mesonbuild/compilers/objcpp.py
@@ -63,7 +63,7 @@ def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_
         ObjCPPCompiler.__init__(self, ccache, exelist, version, for_machine, is_cross,
                                 info, exe_wrapper, linker=linker, full_version=full_version)
         GnuCompiler.__init__(self, defines)
-        default_warn_args = ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor']
+        default_warn_args = ['-Wall', '-Winvalid-pch']
         self.warn_args = {'0': [],
                           '1': default_warn_args,
                           '2': default_warn_args + ['-Wextra'],
@@ -81,7 +81,7 @@ def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_
         ObjCPPCompiler.__init__(self, ccache, exelist, version, for_machine, is_cross,
                                 info, exe_wrapper, linker=linker, full_version=full_version)
         ClangCompiler.__init__(self, defines)
-        default_warn_args = ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor']
+        default_warn_args = ['-Wall', '-Winvalid-pch']
         self.warn_args = {'0': [],
                           '1': default_warn_args,
                           '2': default_warn_args + ['-Wextra'],


Test patch: