[SERVER-14754] Squelch GCC 4.9.1 warnings and linker error Created: 31/Jul/14  Updated: 06/Oct/14  Resolved: 11/Aug/14

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: 2.7.4
Fix Version/s: 2.7.5

Type: Bug Priority: Major - P3
Reporter: Geert Bosch Assignee: Geert Bosch
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

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

Participants:

 Description   

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



 Comments   
Comment by Geert Bosch [ 11/Aug/14 ]

This allows MongoDB to be built with the newest GCC compilers, no change otherwise.

Comment by Githook User [ 01/Aug/14 ]

Author:

{u'username': u'GeertBosch', u'name': u'Geert Bosch', u'email': u'geert.bosch@mongodb.com'}

Message: SERVER-14754: Squelch GCC 4.9.1 warnings and linker error
Branch: master
https://github.com/mongodb/mongo/commit/e88cbe0c83833601f688d8e6b7eb165c8583a4aa

Comment by Geert Bosch [ 31/Jul/14 ]

build/linux2/normal/mongo/db/repl/repl_coordinator_impl.o: In function `mongo::repl::TopologyCoordinatorImpl::~TopologyCoordinatorImpl()':
/home/bosch/mongo/src/mongo/db/repl/topology_coordinator_impl.h:53: undefined reference to `vtable for mongo::repl::TopologyCoordinatorImpl'
collect2: error: ld returned 1 exit status
scons: *** [build/linux2/normal/mongo/db/repl/replica_set_config_checks_test] Error 1
scons: building terminated because of errors.

I thought I had included this... apparently not.

Comment by Eric Milkie [ 31/Jul/14 ]

What is the linker error?

Generated at Thu Feb 08 03:35:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.