Stopping the debugger when the NaN floating point number is done without changing the code

I read this and this . The quintessence is that you can draw a SIGFPE if a nanok is created, including fenv.h and including all floating point exceptions, but FE_INEXACTonfeenableexcept(FE_ALL_EXCEPT & ~FE_INEXACT);

Thus, the code changes shape

int main () {
   double dirty = 0.0;
   double nanvalue = 0.0/dirty;
   return 0;
 }

to

 #include <fenv.h>
 int main () {
     feenableexcept(FE_ALL_EXCEPT & ~FE_INEXACT);  // Enable all floating point exceptions but FE_INEXACT
     double dirty = 0.0;
     double nanvalue = 0.0/dirty;
     return 0;
 }

This works fine, but you need to change the code. I have a problem that in a huge database of c and C ++ code, nan is being created somewhere, and I don't know where. It is not possible to apply the above change to file hits and track the error.

Is there a way to include all floating point exceptions without changing the code? Is there a compilation option that I don't know about?

We use Intel icc compiler version 15.0.3.

+6
1

, , feenableexcept(FE_ALL_EXCEPT & ~FE_INEXACT) main().

, , , ​​ fedisableexcept().

+4

All Articles