Info
When the entire function is wrapped in a WCE retry-loop GCC doesn't deduce that a return statement will be reached.
Error:
src/mongo/db/repl/minvalid.cpp: In function 'bool mongo::repl::getInitialSyncFlag()':
src/mongo/db/repl/minvalid.cpp:95:5: error: control reaches end of non-void function [-Werror=return-type]
}
^
src/mongo/db/repl/sync.cpp: In member function 'virtual bool mongo::repl::Sync::shouldRetry(mongo::OperationContext*, const mongo::BSONObj&)':
src/mongo/db/repl/sync.cpp:158:5: error: control reaches end of non-void function [-Werror=return-type]
}
^
Apparently this was happening with gcc 4.9 as well according to spencer.
Toolchain: gcc 5.1.0 obtained from ubuntu-toolchain-test ppa
g++-5 -v
gcc version 5.1.0 (Ubuntu 5.1.0-0ubuntu11~14.04.1)
Note that this only happens on debug builds.
Top User Comments
xgen-internal-githook commented on Fri, 8 Jan 2016 22:15:33 +0000:
Author:
{u'username': u'amidvidy', u'name': u'Adam Midvidy', u'email': u'amidvidy@gmail.com'}
Message: SERVER-18373 SERVER-18219 add MONGO_UNREACHABLE macro where compiler cannot deduce that WCE retry loops will return
Branch: v3.0
https://github.com/mongodb/mongo/commit/4f7b4de66892c74adc0817776ec059b13678de64
xgen-internal-githook commented on Tue, 28 Apr 2015 22:36:07 +0000:
Author:
{u'username': u'amidvidy', u'name': u'Adam Midvidy', u'email': u'amidvidy@gmail.com'}
Message: SERVER-18219 hint to GCC that WCE loops will actually return
Branch: master
https://github.com/mongodb/mongo/commit/549889cef2d424790cdf82c4a4d372137aaa0439
Steps to Reproduce
Scons invocation:
scons -j24 CC=gcc-5 CXX=g++-5 --cache --dbg=on --opt=off --cache-dir=/media/amidvidy/scons_cache/cache --ssl CCFLAGS="-fuse-ld=gold -fdiagnostics-color=always" mongod