[SERVER-18219] "control reaches end of non-void function" errors in GCC with WCE retry loop Created: 27/Apr/15  Updated: 08/Jan/16  Resolved: 28/Apr/15

Status: Closed
Project: Core Server
Component/s: Replication
Affects Version/s: None
Fix Version/s: 3.0.9, 3.1.3

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

Issue Links:
Related
related to SERVER-18343 'control reaches end of non-void func... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Completed:
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

Sprint: Platform 3 05/15/15
Participants:

 Description   

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.



 Comments   
Comment by Githook User [ 08/Jan/16 ]

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

Comment by Githook User [ 28/Apr/15 ]

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

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