sigfpe

Floating point exception ( SIGFPE ) on 'int main(){ return(0); }'

Deadly 提交于 2019-11-29 20:07:18
I am trying to build a simple C program for two different Linux environments. On one device the program runs fine, on the other device the program generates a floating point exception. The program does nothing but return 0 from main which leads me to believe there is some incompatibility with the start-up code perhaps ABI? The program is compiled with gcc with the following build specs: Using built-in specs. Target: i386-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release -

Division by zero does not throw SIGFPE

南笙酒味 提交于 2019-11-29 05:38:14
I have a small program performing floating-point division by zero, so I expect SIGFPE. #include <sys/types.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> #include <iostream> void signal_handler (int signo) { if(signo == SIGFPE) { std::cout << "Caught FPE\n"; } } int main (void) { signal(SIGFPE,(*signal_handler)); double b = 1.0; double c = 0.0; double d = b/c; std::cout << "d = "<< d << std::endl; return 0; } Actually, I got the following output: d = inf gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4) What should I do to throw SIGFPE in this case? Which factors FP operation

Floating point exception ( SIGFPE ) on 'int main(){ return(0); }'

霸气de小男生 提交于 2019-11-28 15:54:40
问题 I am trying to build a simple C program for two different Linux environments. On one device the program runs fine, on the other device the program generates a floating point exception. The program does nothing but return 0 from main which leads me to believe there is some incompatibility with the start-up code perhaps ABI? The program is compiled with gcc with the following build specs: Using built-in specs. Target: i386-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr

Division by zero does not throw SIGFPE

纵然是瞬间 提交于 2019-11-27 23:16:58
问题 I have a small program performing floating-point division by zero, so I expect SIGFPE. #include <sys/types.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> #include <iostream> void signal_handler (int signo) { if(signo == SIGFPE) { std::cout << "Caught FPE\n"; } } int main (void) { signal(SIGFPE,(*signal_handler)); double b = 1.0; double c = 0.0; double d = b/c; std::cout << "d = "<< d << std::endl; return 0; } Actually, I got the following output: d = inf gcc version 4.5.2