[SERVER-10142] Eliminate Compiler Warnings on Windows Builders Created: 09/Jul/13  Updated: 11/Jul/16  Resolved: 14/Jan/14

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: None
Fix Version/s: 2.5.5

Type: Improvement Priority: Major - P3
Reporter: Andy Schwerin Assignee: Mark Benvenuto
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Participants:

 Description   

We should work to either suppress or fix all outstanding warnings from the Windows compiler and linker.
Afterwards, we should then promote all warnings to errors, to break the build if any new warnings appear.
Third-party code should be specially treated to suppress most warnings, via their SConscripts.

Original description:

Latest set of compiler warnings from MCI Windows 64-bit. Not shown here are warnings from src/third_party.

MCI link: http://mci.10gen.com/ui/task_log_raw/mongodb_mongo_master_windows_64_a6678a47b6e2700a502984cc1b990ded37f61c7f_13_11_01_05_54_06_compile?type=task

[2013/11/01 06:01:41.248] src\mongo\util\intrusive_counter.cpp(45) : warning C4291: 'void *mongo::RCString::operator new(size_t,size_t)' : no matching operator delete found; memory will not be freed if initialization throws an exception
[2013/11/01 06:01:56.150] src\mongo\util\net\httpclient.cpp(143) : warning C4101: 'se' : unreferenced local variable
[2013/11/01 06:06:12.609] src\mongo\util\net\miniwebserver.cpp(128) : warning C4101: 'se' : unreferenced local variable
[2013/11/01 06:14:37.655] src\mongo\db\commands\storage_details.cpp(85) : warning C4351: new behavior: elements of array 'mongo::`anonymous-namespace'::DiskStorageData::freeRecords' will be default initialized
[2013/11/01 06:16:20.871] D:\data\mci\git@github.commongodb\mongo.git\master\src\mongo/s/chunk_manager_targeter.h(122) : warning C4099: 'mongo::TargeterStats' : type name first seen using 'class' now seen using 'struct'
[2013/11/01 06:17:01.347] D:\data\mci\git@github.commongodb\mongo.git\master\src\mongo/s/chunk_manager_targeter.h(122) : warning C4099: 'mongo::TargeterStats' : type name first seen using 'class' now seen using 'struct'
[2013/11/01 06:17:27.038] src\mongo\tools\restore.cpp(118) : warning C4101: 'error' : unreferenced local variable
[2013/11/01 06:20:58.223] src\mongo\client\examples\authTest.cpp(74) : warning C4101: 'e' : unreferenced local variable
[2013/11/01 06:22:14.001] src\mongo\util\intrusive_counter.cpp(45) : warning C4291: 'void *mongo::RCString::operator new(size_t,size_t)' : no matching operator delete found; memory will not be freed if initialization throws an exception
[2013/11/01 06:22:16.873] src\mongo\util\net\httpclient.cpp(143) : warning C4101: 'se' : unreferenced local variable
[2013/11/01 06:23:12.028] D:\data\mci\git@github.commongodb\mongo.git\master\src\mongo/s/chunk_manager_targeter.h(122) : warning C4099: 'mongo::TargeterStats' : type name first seen using 'class' now seen using 'struct'
[2013/11/01 06:25:43.328] src\mongo\dbtests\updatetests.cpp(1058) : warning C4065: switch statement contains 'default' but no 'case' labels
[2013/11/01 06:25:43.329] src\mongo\dbtests\updatetests.cpp(1090) : warning C4065: switch statement contains 'default' but no 'case' labels
[2013/11/01 06:30:01.197] src\mongo\util\options_parser\options_parser_test.cpp(63) : warning C4101: 'e' : unreferenced local variable
[2013/11/01 06:30:01.198] src\mongo\util\options_parser\options_parser_test.cpp(74) : warning C4101: 'e' : unreferenced local variable
[2013/11/01 06:30:01.199] src\mongo\util\options_parser\options_parser_test.cpp(87) : warning C4101: 'e' : unreferenced local variable
[2013/11/01 06:30:01.201] src\mongo\util\options_parser\options_parser_test.cpp(98) : warning C4101: 'e' : unreferenced local variable
[2013/11/01 06:30:01.201] src\mongo\util\options_parser\options_parser_test.cpp(105) : warning C4101: 'e' : unreferenced local variable
[2013/11/01 06:30:01.210] src\mongo\util\options_parser\options_parser_test.cpp(112) : warning C4101: 'e' : unreferenced local variable
[2013/11/01 06:30:01.210] src\mongo\util\options_parser\options_parser_test.cpp(119) : warning C4101: 'e' : unreferenced local variable
[2013/11/01 06:30:01.210] src\mongo\util\options_parser\options_parser_test.cpp(126) : warning C4101: 'e' : unreferenced local variable
[2013/11/01 06:30:01.210] src\mongo\util\options_parser\options_parser_test.cpp(137) : warning C4101: 'e' : unreferenced local variable
[2013/11/01 06:30:01.210] src\mongo\util\options_parser\options_parser_test.cpp(148) : warning C4101: 'e' : unreferenced local variable
[2013/11/01 06:30:01.210] src\mongo\util\options_parser\options_parser_test.cpp(159) : warning C4101: 'e' : unreferenced local variable
[2013/11/01 06:30:01.210] src\mongo\util\options_parser\options_parser_test.cpp(174) : warning C4101: 'e' : unreferenced local variable
[2013/11/01 06:30:01.210] src\mongo\util\options_parser\options_parser_test.cpp(186) : warning C4101: 'e' : unreferenced local variable
[2013/11/01 06:30:01.210] src\mongo\util\options_parser\options_parser_test.cpp(201) : warning C4101: 'e' : unreferenced local variable
[2013/11/01 06:30:01.214] src\mongo\util\options_parser\options_parser_test.cpp(213) : warning C4101: 'e' : unreferenced local variable
[2013/11/01 06:30:01.310] src\mongo\util\options_parser\options_parser_test.cpp(1470) : warning C4101: 'e' : unreferenced local variable
[2013/11/01 06:30:12.720] src\mongo\util\time_support_test.cpp(41) : warning C4996: 'putenv': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _putenv. See online help for details.
[2013/11/01 06:30:12.720] src\mongo\util\time_support_test.cpp(44) : warning C4996: 'tzset': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _tzset. See online help for details.
[2013/11/01 06:30:34.361] src\mongo\bson\bson_validate_test.cpp(101) : warning C4309: '=' : truncation of constant value

================
Here are the warnings, from mutable, updatetests, and working_set.

http://buildbot.mongodb.org:8081/builders/Windows%2064-bit/builds/5597/steps/compile/logs/warnings%20%2813%29

src\mongo\bson\mutable\document.cpp(2570) : warning C4390: ';' : empty controlled statement found; is this the intent?
namespace.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
pch.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
D:\slave\Windows_64bit\mongo\src\mongo/db/exec/working_set_common.h(21) : warning C4099: 'mongo::WorkingSetMember' : type name first seen using 'struct' now seen using 'class'
D:\slave\Windows_64bit\mongo\src\mongo/db/exec/working_set_common.h(21) : warning C4099: 'mongo::WorkingSetMember' : type name first seen using 'struct' now seen using 'class'
src\mongo\db\commands\storage_details.cpp(85) : warning C4351: new behavior: elements of array 'mongo::`anonymous-namespace'::DiskStorageData::freeRecords' will be default initialized
src\mongo\tools\restore.cpp(152) : warning C4101: 'error' : unreferenced local variable
mutexdebugger.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
pch.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
namespace.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
D:\slave\Windows_64bit\mongo\src\mongo/db/exec/working_set_common.h(21) : warning C4099: 'mongo::WorkingSetMember' : type name first seen using 'struct' now seen using 'class'
src\mongo\dbtests\updatetests.cpp(1053) : warning C4065: switch statement contains 'default' but no 'case' labels
src\mongo\dbtests\updatetests.cpp(1085) : warning C4065: switch statement contains 'default' but no 'case' labels



 Comments   
Comment by Githook User [ 14/Jan/14 ]

Author:

{u'username': u'markbenvenuto', u'name': u'Mark Benvenuto', u'email': u'mark.benvenuto@mongodb.com'}

Message: SERVER-10142: Eliminate Compiler Warnings on Windows Builders
Branch: master
https://github.com/mongodb/mongo/commit/1ca54ce0c33b691b1427e2b9f4a709835a02e25e

Comment by Githook User [ 18/Dec/13 ]

Author:

{u'username': u'markbenvenuto', u'name': u'Mark Benvenuto', u'email': u'mark.benvenuto@mongodb.com'}

Message: SERVER-10142: Eliminate Compiler Warnings on Windows Builders
BF-60:compile broken on windows
Branch: master
https://github.com/mongodb/mongo/commit/5d54ce99eb7c805f567419f1d473b818fff10bdf

Comment by auto [ 10/Jul/13 ]

Author:

{u'username': u'acmorrow', u'name': u'Andrew Morrow', u'email': u'acm@10gen.com'}

Message: SERVER-10142 Fix windows warning for cases where dassert is compiled out
Branch: master
https://github.com/mongodb/mongo/commit/11989a1f968d632eb78c8d6347b71ca39ef9ff80

Comment by Andrew Morrow (Inactive) [ 09/Jul/13 ]

We actually already suppress the mismatched tag warnings (class vs struct) for GCC and clang: https://github.com/mongodb/mongo/blob/master/SConstruct#L1068-L1072 so it seems very reasonable to do so on Windows too.

Comment by Eric Milkie [ 09/Jul/13 ]

If any of these warnings are simply ones we do not care too much about (considering that gcc and clang do not report them), we can easily disable individual warnings on Windows via their warning code.

Comment by Andrew Morrow (Inactive) [ 09/Jul/13 ]

The one in mutable/document.cpp is spurious: https://github.com/mongodb/mongo/blob/master/src/mongo/bson/mutable/document.cpp#L2568-L2569. The dassert is getting compiled out, so the statement reduces to

if (fieldName);

. I will move it into a dev block to silence this.

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