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

Squelch GCC 4.9.1 warnings and linker error

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.7.5
    • Affects Version/s: 2.7.4
    • Component/s: Internal Code
    • None
    • Fully Compatible
    • ALL
    • Hide

      On Ubuntu 14.04, install GCC 4.9.1 and run "scons all".

      Show
      On Ubuntu 14.04, install GCC 4.9.1 and run "scons all".
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      GCC 4.9.1 generates the warnings included below, as well as a linker error due to a (unneeded) desctructor.

      I have a patch that fixes this by initializing some out parameters even in case of an error, and by removing the unneeded destructor. Will submit for code review.

      g++ -o build/linux2/normal/mongo/db/commands/index_filter_commands.o -c -Wnon-virtual-dtor -Woverloaded-virtual -std=c++11 -fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -pipe -Werror -O3 -Wno-unused-local-typedefs -Wno-unused-function -Wno-deprecated-declarations -Wno-unused-but-set-variable -fno-builtin-memcmp -DBOOST_ALL_NO_LIB -D_SCONS -DMONGO_EXPOSE_MACROS -DSUPPORT_UTF8 -DMONGO_OPTIMIZED_BUILD -D_FILE_OFFSET_BITS=64 -DMONGO_HAVE___THREAD -DMONGO_HAVE_CXX11_ATOMICS -DMONGO_HAVE_HEADER_UNISTD_H -DMONGO_HAVE_POSIX_MONOTONIC_CLOCK -DMONGO_HAVE_EXECINFO_BACKTRACE -Isrc/third_party/boost -Isrc/third_party/s2 -Isrc/third_party/pcre-8.30 -Ibuild/linux2/normal -Isrc -Isrc/third_party/snappy src/mongo/db/commands/index_filter_commands.cpp
      src/mongo/db/commands/index_filter_commands.cpp: In member function 'virtual mongo::Status mongo::ClearFilters::runIndexFilterCommand(mongo::OperationContext*, const string&, mongo::BSONObj&, mongo::BSONObjBuilder*)':
      src/mongo/db/commands/index_filter_commands.cpp:243:63: error: 'querySettings' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      return clear(txn, querySettings, planCache, ns, cmdObj);
      ^
      src/mongo/db/commands/index_filter_commands.cpp:243:63: error: 'planCache' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      src/mongo/db/commands/index_filter_commands.cpp: In member function 'virtual mongo::Status mongo::ListFilters::runIndexFilterCommand(mongo::OperationContext*, const string&, mongo::BSONObj&, mongo::BSONObjBuilder*)':
      src/mongo/db/commands/index_filter_commands.cpp:183:40: error: 'querySettings' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      return list(*querySettings, bob);
      ^
      src/mongo/db/commands/index_filter_commands.cpp: In member function 'virtual mongo::Status mongo::SetFilter::runIndexFilterCommand(mongo::OperationContext*, const string&, mongo::BSONObj&, mongo::BSONObjBuilder*)':
      src/mongo/db/commands/index_filter_commands.cpp:336:61: error: 'querySettings' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      return set(txn, querySettings, planCache, ns, cmdObj);
      ^
      src/mongo/db/commands/index_filter_commands.cpp:336:61: error: 'planCache' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      cc1plus: all warnings being treated as errors
      scons: *** [build/linux2/normal/mongo/db/commands/index_filter_commands.o] Error 1

            Assignee:
            geert.bosch@mongodb.com Geert Bosch
            Reporter:
            geert.bosch@mongodb.com Geert Bosch
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              None
              None
              None
              None