Common reasons for bugs in release version not present in debug mode

错误和异常程序行为的典型原因是什么,它们仅在释放编译模式下表现出来,但在调试模式下不会发生?


Many times, in debug mode in C++ all variables are null initialized, whereas the same does not happen in release mode unless explicitly stated.

Check for any debug macros and uninitialized variables

Does your program uses threading, then optimization can also cause some issues in release mode.

Also check for all exceptions, for example not directly related to release mode but sometime we just ignore some critical exceptions, like mem access violation in VC++, but the same can be a issue at least in other OS like Linux, Solaris. Ideally your program should not catch such critical exceptions like accessing a NULL pointer.


常见的陷阱是在ASSERT中使用带有副作用的表达式。


Other differences might be:

  • In a garbage-collected language, the collector is usually more aggressive in release mode;
  • Layout of memory may often be different;
  • Memory may be initialized differently (eg could be zeroed in debug mode, or re-used more aggressively in release);
  • Locals may be promoted to register values in release, which can cause issues with floating point values.
  • 链接地址: http://www.djcxy.com/p/80606.html

    上一篇: 调试与发布性能

    下一篇: 在调试模式下,发布版本中缺陷的常见原因不存在