[bind10-dev] Compiler -Whining

Shane Kerr shane at isc.org
Fri Feb 5 10:11:21 UTC 2010


All,

I saw that we added -Woverloaded-virtual in one of the recent Subversion
changesets. Based on the man page, this seems entirely good:

           Warn when a function declaration hides virtual functions from a
           base class.  For example, in:

                   struct A {
                     virtual void f();
                   };

                   struct B: public A {
                     void f(int);
                   };

           the "A" class version of "f" is hidden in "B", and code like:

                   B* b;
                   b->f();

           will fail to compile.

In fact, I wonder why there's no equivalent warning for non-virtual
functions:

                   struct A {
                     void f();
                   };

                   struct B: public A {
                     void f();
                   };

At least this is almost certainly an error. This is Item 36 in Effective
C++: "Never redefine an inherited non-virtual function". Weirdly, there
is a warning based entirely on the book:

       -Weffc++ (C++ and Objective-C++ only)
           Warn about violations of the following style guidelines from Scott
           Meyers' Effective C++ book:

Which for some reason does not include Item 36. Oh well.

For the record, I love enabling compiler warnings. There should be
-Wreallyall, or perhaps -Wextra++...

--
Shane




More information about the bind10-dev mailing list