Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-1486

DBClientPaired::auth shadows virtual function DBClientWithCommands::auth, causes warnings with -Wall -Werror -Woverloaded-virtual

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.5.7
    • Affects Version/s: 1.5.6
    • Component/s: Internal Client
    • Labels:
      None
    • Environment:
      Unbuntu 10.04 x86_64, gcc 4.2

      When compiling against the C++ driver headers in a project which uses -Woverloaded-virtual, gcc complains as follows:

      cc1plus: warnings being treated as errors
      In file included from /tmp/mongo-tmp-install/include/mongo/client/connpool.h:21,
      from db/AccessControl.cc:3:
      /tmp/mongo-tmp-install/include/mongo/client/dbclient.h: At global scope:
      /tmp/mongo-tmp-install/include/mongo/client/dbclient.h:390: error: 'virtual bool mongo::DBClientWithCommands::auth(const std::string&, const std::string&, const std::string&, std::string&, bool)' was hidden
      /tmp/mongo-tmp-install/include/mongo/client/dbclient.h:899: error: by 'bool mongo::DBClientPaired::auth(const std::string&, const std::string&, const std::string&, std::string&)'

      Shadowing virtual functions like this is typically pretty bad practice, since it makes it very non-obvious at the call-site what is going on. Also, -Woverloaded-virtual is a fairly common warning flag to enable.

            Assignee:
            alerner Alberto Lerner
            Reporter:
            andrew.morrow@mongodb.com Andrew Morrow (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: