Can I get exception when operation return 0.#INF
Is there any setting in MS VS2008 to generate exception if operation return 0.#INF? Using usual debugging doesn开发者_运维技巧't help me because I can't figure out where it's occured.
You can use _control87 to enable division-by-zero exceptions. Like this:
#include "stdafx.h"
#include <float.h>
int _tmain(int argc, _TCHAR* argv[])
{
#ifdef _DEBUG
_control87( ~_EM_ZERODIVIDE, _MCW_EM );
#endif
double value = 1;
value /= 0; // kaboom
return 0;
}
Use this only to diagnose the bug. Changing the FPU control word is very destabilizing to libraries that expect the FPU to have its default initialization.
There is an Enable Floating Point Exceptions in the C/C++->Code Generation of your apps properties
精彩评论