Compile a program with clang to ignore arithmetic errors (SIGFPE)

47 Views Asked by At

If I understand this correctly, division by zero is undefined behavior. The compiler may or may not add an instruction that checks if the operation is valid and causes error if it is not a valid operation.

I am compiling my program with code that I cannot change and that does cause floating point error.

In particular it does this:

511952 % 0

And it prints this at startup:

Floating point exception

Now I remember from a different project there are different ways to handle this, in fact one of my tasks on that project was fix all floating point errors once we ENABLED the floating point exception. Prior to that, division by 0 would produce the special NaN floating point value.

So can I tell clang to not produce any code that would handle the floating point error and just ignore it? I'd love to fix it but can't and I know it works even with this error.

0

There are 0 best solutions below