If one compiles using x86 SSE options then floating point exceptions cause a SIGFPE signal and one's code will terminate without any message. This includes, surprisingly, even divide-by-zero errors cause by modulus arithmetic with integers. Here's a code fragment to illustrate things:
Code: Select all
#define __USE_GNU
#include <fenv.h> // floating point exceptions that cause a SIGFPE
void fpe_handler(int sig_num)
{
printf("** error ** a floating point exception occured # %d\n", sig_num);
printf("press <Enter> to close window ");
getchar();
exit(sig_num);
}
int enable_floating_point_exception_tests(void)
{
feenableexcept(FE_DIVBYZERO);
signal(SIGFPE, fpe_handler);
// test code to exercise the floating point exception
volatile int a,b;
a = 1;
b = 1; // set b = 1 for no exception set b = 0 to cause one
return a % b;
}