[MDEV-7435] Windows debug: Run-Time Check Failure #3 - The variable 'unused' is being used without being initialized Created: 2015-01-12  Updated: 2015-02-08  Resolved: 2015-02-06

Status: Closed
Project: MariaDB Server
Component/s: Compiling, Platform Windows
Affects Version/s: 5.5, 10.0
Fix Version/s: 5.5.42, 10.0.16

Type: Bug Priority: Blocker
Reporter: Elena Stepanova Assignee: Alexey Botchkov
Resolution: Fixed Votes: 0
Labels: Windows, buildbot, compile

Issue Links:
Relates
relates to MDEV-7069 Fix buildbot failures in main server ... Stalled

 Description   

http://buildbot.askmonty.org/buildbot/builders/win32-debug2/builds/6784/steps/build/logs/stdio

128>  CMake Error at C:/bzr/bb-win32/win32-debug2/build/sql/create_initial_db.cmake:84 (MESSAGE):
 
128>    Could not create initial database
 
128>CUSTOMBUILD : error : Run-Time Check Failure #3 - The variable 'unused' is being used without being initialized. At c:\bzr\bb-win32\win32-debug2\build\sql-common\client_plugin.c:258

Started happening from this revision:

revno: 4394
revision-id: svoj@mariadb.org-20141219191759-zi3qaqyj0vvkh0ba
parent: sergii@pisem.net-20141219104403-wo7bvoif9zii3ie5
committer: Sergey Vojtovich <svoj@mariadb.org>
branch nick: 5.5
timestamp: Fri 2014-12-19 23:17:59 +0400
message:
  Fixed a couple of compiler warnings.



 Comments   
Comment by Sergey Vojtovich [ 2015-01-12 ]

holyfoot, could you have a look at this?

This build failed on warnings. It seem to be enabled implicitly by "cmake --build . --config Debug", that is by Debug project configuration. See MSVC manual for build configurations description: http://msdn.microsoft.com/en-us/library/wx0123s5.aspx

For such builds we should add definition of FORCE_INIT_OF_VARS. Probably the easiest way is to add set_property(GLOBAL APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG FORCE_INIT_OF_VARS) to cmake/Windows.cmake.

Comment by Elena Stepanova [ 2015-02-05 ]

The problem was already fixed in 10.0.16 by the revision below; but on 5.5 the build still fails.

revno: 4587
revision-id: sergii@pisem.net-20150123131738-ia1mjsnd383fmmg0
parent: knielsen@knielsen-hq.org-20150123125646-4lazb1074epizgyg
committer: Sergei Golubchik <sergii@pisem.net>
branch nick: 10.0
timestamp: Fri 2015-01-23 14:17:38 +0100
message:
  win32-debug build failure

Comment by Alexey Botchkov [ 2015-02-06 ]

Same fix pushed to the 5.5.
In the future though i think the nicer fix is to turn /nowarn:42024 switch on,
so the VC won't warn the unused local variables.

Comment by Vladislav Vaintroub [ 2015-02-08 ]

The build does not fail on warnings. It is runtime error tells you that variable is used and its value was read. It makes sense to find out why it was so.

Comment by Alexey Botchkov [ 2015-02-08 ]

Ah, of course i meant to switch it off for the Release build only. Debug should still fail on the uninitialized variables.

Comment by Vladislav Vaintroub [ 2015-02-08 ]

Runtime checks (/RTC flags in Visual C++) are never enabled in optimized builds, since they are very expensive in terms of peformance.
They are enabled by default in debug builds
https://msdn.microsoft.com/en-us/library/162azb0k.aspx

I guess a better solution would be to treat corresponding warnings C4701 and C4703 as errors (using /we4701 /we4703 or #pragma warning (error : 4701)), so that compilation fails rather than program crashes at runtime. Visual C++ compiler is pretty accurate on such warnings, not known for many false positives

Generated at Thu Feb 08 07:19:34 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.