I am struggling to get a reliable way to catch floating points exceptions under Visual Studio (2005 or 2008). By default, under visual studio, floating point exceptions are not
Additional information: If you are running 32-bit code on 64-bit windows, and use /arch:SSE2 or other options that enable the SSE2 instruction set, or one of its supersets, you may need to do a more drastic reset.
With Visual Studio 2015 (and, presumably, later versions), you need to call _fpreset() after floating-point traps generated in the SSE2 registers, rather than just _clearfp(). If you do this with Visual Studio 2013 and earlier, you get a variety of weird problems, caused by the run-time library getting confused.
You have to clear the FPU exception flags in the status word when you catch a floating point exception. Call _clearfp().
Consider using _set_se_translator() to write an exception filter that translate the hardware exception to a C++ exception. Be sure to be selective, only translate the FPU exceptions.