How to debug a variable that is optimized away in Release build

前端 未结 2 1297
后悔当初
后悔当初 2021-02-08 18:04

I am using VS2010. My debug version works fine however my Release version kept on crashing. So In the release version mode I right clicked the project chose Debug and then chose

2条回答
  •  我在风中等你
    2021-02-08 18:37

    If you debug release build the debugger will report bogus values or will not be able to display any values for most of your variables. The safest way to check that the value of a variable is in Release build is to use logging.

    So most probably your array is initialized in Release just as in Debug build but you are not able to see that through the debugger. It seems you have some other problem that is causing the code to crash in Release. Look for some other uninitialized variable or some stack corruption/index out of bounds access.

提交回复
热议问题