Sometimes a program crashes or simply misbehaves on release builds. This is very frustrating because usually you have to ship the optimized release version. The most common reason for this phenomenon is that some code is executed in _DEBUG mode only. This can happen if you place some important code inside the #ifdef block:
#ifdef _DEBUGm_nInportantGuy = 0; // oops#endif
Sometimes, you might have placed code with side effects within an ASSERT or TRACE statement: TRACE(“My file : %s”, OpenAndGetFileName());
Since these statements vanish in release build, you will get different behavior. The way to avoid these problems is to pay attention and do the important stuff before calling the TRACE or ASSERT:
const char * sFilename = OpenAndGetFilename();TRACE("My file : %s", sFilename);