At times it is possible that some operations work fine in Debug mode but not in Release mode and vice-versa.
Here are the some of the common errors that lead us to the above problem.
1. In general, the default value of an uninitialzed variable is garbage in Debug and zero in Release .
So, the following code works fine in Debug and not in Release .
if( enabled )
So, Please initialise when a variable is declared.
2. One of the main difference in Debug and Release is Optimization.
We can set this from Properties -> C/C++ -> Optimization.
By default, optimization is turned off in the Debug configuration of a Visual C++ program and turned on in the Release configuration.
Sometimes, however, a bug may appear only in an optimized version of a program. In that case, we must debug the optimized code.
Here are some techniques to test the application
– Set the mode Debug and Optimization level is should be same as Release and now run the application.
– Set the Release mode and change the Optimization level and run the application.
3. Check the _DEBUG macro in the code. where it is used and How it is used.
Look for any code that is inside of a “#ifdef _DEBUG” wrapper that might be needed in the Release version.
4. Sometimes Warnings are important.
When starting a project turn the warning level to “Level 3” or “Level 4” and make sure the code compiles with minimal or no warnings.