Jump to content
  • Advertisement
Sign in to follow this  
SymLinked

[MSVC]: Automatic variable initialization in debug builds. How does one disable it?

This topic is 3497 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

My release builds exhibit bugs that do not show up in debug builds. This is driving me nuts. I've been trying to play around with RTC1 and related options but none of them seem to be related to this 'feature'. Is there a way to turn this off, perhaps via pragmas?

Share this post


Link to post
Share on other sites
Advertisement
If you're referring to stack variables being initialized with predetermined values, that's controlled by /RTCs. If you're referring to heap memory being initialized with predetermined values, that's controlled by which version of the CRT you link against.

Share this post


Link to post
Share on other sites
You can also run the debugger on the release build. This is necessary sometimes when a bug only manifests itself in the presence of optimizations. Take a release build, turn on debug info, and viola. Debuggable release build.

Share this post


Link to post
Share on other sites
One thing worth noting here is that Windows itself will initialize heap memory for you if a debugger is connected at application startup.

The easiest way around this is to start the program without debugging, and then attach the debugger to the running process.

Share this post


Link to post
Share on other sites
Quote:
Original post by SymLinked
My release builds exhibit bugs that do not show up in debug builds. This is driving me nuts.


Be aware that there are far more potential reasons for this than just the variable initialization thing. :)

Share this post


Link to post
Share on other sites
Not to be douche-y, but why don't you just initialize your variables?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!