Jak*_* M. 3 c c++ assert segmentation-fault
我有相当多的代码,在开发版本中运行良好,assert()代码中有许多代码.我-DNDEBUG通过传递给g ++的指令禁用了断言,现在我的代码打破了seg.故障.有关assert()的东西我不知道吗?
根据我的知识断言最常见的问题是在断言本身中具有副作用的代码.使用-DNDEBUG进行编译时,断言基本上已被注释掉,因此不执行断言内的代码.assert手册页在bug部分提到了这一点:
BUGS
assert() is implemented as a macro; if the expression tested has side-
effects, program behavior will be different depending on whether NDEBUG
is defined. This may create Heisenbugs which go away when debugging is
turned on.
Run Code Online (Sandbox Code Playgroud)