[SERVER-17235] unused-variable and uninitialized parameter with gcc5.0 Created: 09/Feb/15  Updated: 27/Apr/15  Resolved: 10/Feb/15

Status: Closed
Project: Core Server
Component/s: Build
Affects Version/s: 2.6.7
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Marek Skalický Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Operating System: ALL
Steps To Reproduce:

Build mongoDB 2.6.7 with gcc 5.0.0

Builded by

scons all \
--use-system-all \
--usev8 \
--nostrip \
--ssl \
--disable-warnings-as-errors

Participants:

 Description   

mongoDB 2.6.7 fails to build with gcc 5.0 .

There is problem with this:
-------------------------------------------------------------------
src/mongo/base/global_initializer.cpp:32:18: error: 'mongo::

{anonymous}

::_theGlobalInitializer' defined but not used [-Werror=unused-variable]
Initializer* _theGlobalInitializer = &getGlobalInitializer();
^
-------------------------------------------------------------------
and also

-------------------------------------------------------------------
src/mongo/db/commands/index_filter_commands.cpp: In member function 'virtual mongo::Status mongo::ClearFilters::runIndexFilterCommand(const string&, mongo::BSONObj&, mongo::BSONObjBuilder*)':
src/mongo/db/commands/index_filter_commands.cpp:236:58: error: 'querySettings' may be used uninitialized in this function [-Werror=maybe-uninitialized]
return clear(querySettings, planCache, ns, cmdObj);
^
src/mongo/db/commands/index_filter_commands.cpp:236:58: 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::SetFilter::runIndexFilterCommand(const string&, mongo::BSONObj&, mongo::BSONObjBuilder*)':
src/mongo/db/commands/index_filter_commands.cpp:320:56: error: 'querySettings' may be used uninitialized in this function [-Werror=maybe-uninitialized]
return set(querySettings, planCache, ns, cmdObj);
^
src/mongo/db/commands/index_filter_commands.cpp:320:56: 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(const string&, mongo::BSONObj&, mongo::BSONObjBuilder*)':
src/mongo/db/commands/index_filter_commands.cpp:179:40: error: 'querySettings' may be used uninitialized in this function [-Werror=maybe-uninitialized]
return list(*querySettings, bob);
^

-------------------------------------------------------------------
also with --disable-warnings-as-errors :

-------------------------------------------------------------------
src/mongo/db/commands/plan_cache_commands.cpp: In member function 'virtual mongo::Status mongo::PlanCacheListQueryShapes::runPlanCacheCommand(const string&, mongo::BSONObj&, mongo::BSONObjBuilder*)':
src/mongo/db/commands/plan_cache_commands.cpp:223:36: warning: 'planCache' may be used uninitialized in this function [-Wmaybe-uninitialized]
return list(*planCache, bob);
^
src/mongo/db/commands/plan_cache_commands.cpp: In member function 'virtual mongo::Status mongo::PlanCacheClear::runPlanCacheCommand(const string&, mongo::BSONObj&, mongo::BSONObjBuilder*)':
src/mongo/db/commands/plan_cache_commands.cpp:267:43: warning: 'planCache' may be used uninitialized in this function [-Wmaybe-uninitialized]
return clear(planCache, ns, cmdObj);
^

src/mongo/db/commands/plan_cache_commands.cpp:338:48: warning: 'planCache' may be used uninitialized in this function [-Wmaybe-uninitialized]
return list(*planCache, ns, cmdObj, bob);
^
-------------------------------------------------------------------

I suggest this could be fixed by adding -Wno-unused-variable and -Wno-maybe-uninitialized into SConstruct.
(same as -Wno-unused-function,...)

I don't tried it, but guess this affects all mongoDB versions...



 Comments   
Comment by Andrew Morrow (Inactive) [ 10/Feb/15 ]

Hi mskalick -

I'm going to close this as works as designed, because I don't think we will be taking any further action in response to this information. Please feel free to re-open this ticket if there is anything more that we can do to help.

Thanks,
Andrew

Comment by Andrew Morrow (Inactive) [ 10/Feb/15 ]

Hi mskalick -

Correct: we have not yet validated our build with gcc-4.9 or newer, so we have not had an opportunity to evaluate novel warnings and decide if they indicate real latent issues in our code, are compiler false positives, or are something we just want to suppress. Until we do so, you will need to use --disable-warnings-as-errors if you are using GCC newer than 4.8.

Thanks,
Andrew

Comment by Marek Skalický [ 10/Feb/15 ]

No, sorry for confusion. With --disable-warnings-as-errors it works fine.

In the second part I only want to report where the problems (warnings) are...

I haven't tried to build mongoDB 3.0 yet, but in the code (SConstruct) I haven't found similar gcc options.

Comment by Andrew Morrow (Inactive) [ 09/Feb/15 ]

Hi -

I'm a little confused by the second part of your description: are you saying that it still fails to build when using --disable-warnings-as-errors? Or only that it still issues warnings? We are unlikely to take any action on a maintenance branch to address warnings from newer compilers: such a situation is exactly the motivation for providing the --disable-warnings-as-errors option.

Do these same warnings occur on the master branch?

Also, please note that GCC 5 is still in development, and we are unlikely to begin testing with it until it is officially released. In particular, we don't want to spend time chasing false positive warnings that may not be presenting in the shipping version of the compiler.

Thanks,
Andrew

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