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

Invalid noncopyable logic in MongoDB C++ client (src/mongo/util/goodies.h)

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 2.4.0-rc2
    • Component/s: Internal Code
    • Labels:
      None
    • Environment:
      Linux / g++
    • Linux
    • Hide

      Compile with g++ against C++ client library with -Wextra flag.

      Show
      Compile with g++ against C++ client library with -Wextra flag.

      I get this warning when compiling against MongoDB C++ client library:

      ...mongo/util/goodies.h:136: warning: base class ‘class boost::noncopyable_::noncopyable’ should be explicitly initialized in the copy constructor

      src/mongo/util/goodies.h has the following code:

      class ThreadSafeString : boost::noncopyable {
      public:
      ThreadSafeString( size_t size=256 )
      : _size( size ) , _buf( new char[size] )

      { memset( _buf , 0 , _size ); }

      ThreadSafeString( const ThreadSafeString& other )
      : _size( other._size ) , _buf( new char[_size] )

      { strncpy( _buf , other._buf , _size ); }

      What is the point first deriving from private boost::noncopyable and then defining a copy constructor with a body? It defeats the purpose. Either it could just define a private copy constructor, or define none at all and privately derive from boost::noncopyable.
      Either way it would avoid this warning.

            Assignee:
            Unassigned Unassigned
            Reporter:
            shmerl Hillel Lubman
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: