diff --git a/src/OSD/OSD_signal.cxx b/src/OSD/OSD_signal.cxx index 4e2f1c15f1..4365715733 100644 --- a/src/OSD/OSD_signal.cxx +++ b/src/OSD/OSD_signal.cxx @@ -872,7 +872,6 @@ static void SegvHandler(const int theSignal, void OSD::SetSignal(const Standard_Boolean aFloatingSignal) { - static int first_time = 3 ; struct sigaction act, oact; int stat = 0; @@ -894,27 +893,25 @@ void OSD::SetSignal(const Standard_Boolean aFloatingSignal) } #elif defined (__linux__) feenableexcept (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW); - //feenableexcept (FE_INVALID | FE_DIVBYZERO); fFltExceptions = Standard_True; #endif } - else if ( first_time & 1 ) { -// cout << "SetSignal( Standard_False ) is not implemented..." << endl ; - first_time = first_time & (~ 1) ; + else + { +#if defined (__linux__) + fedisableexcept (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW); + fFltExceptions = Standard_False; +#endif } #if defined (sgi) || defined (IRIX ) - if ( first_time & 2 ) { - char *TRAP_FPE = getenv("TRAP_FPE") ; - if ( TRAP_FPE == NULL ) { + char *TRAP_FPE = getenv("TRAP_FPE") ; + if ( TRAP_FPE == NULL ) { #ifdef OCCT_DEBUG - cout << "On SGI you must set TRAP_FPE environment variable : " << endl ; - cout << "set env(TRAP_FPE) \"UNDERFL=FLUSH_ZERO;OVERFL=DEFAULT;DIVZERO=DEFAULT;INT_OVERFL=DEFAULT\" or" << endl ; - cout << "setenv TRAP_FPE \"UNDERFL=FLUSH_ZERO;OVERFL=DEFAULT;DIVZERO=DEFAULT;INT_OVERFL=DEFAULT\"" << endl ; + cout << "On SGI you must set TRAP_FPE environment variable : " << endl ; + cout << "set env(TRAP_FPE) \"UNDERFL=FLUSH_ZERO;OVERFL=DEFAULT;DIVZERO=DEFAULT;INT_OVERFL=DEFAULT\" or" << endl ; + cout << "setenv TRAP_FPE \"UNDERFL=FLUSH_ZERO;OVERFL=DEFAULT;DIVZERO=DEFAULT;INT_OVERFL=DEFAULT\"" << endl ; #endif -// exit(1) ; - first_time = first_time & (~ 2) ; - } } #endif diff --git a/src/QABugs/QABugs_20.cxx b/src/QABugs/QABugs_20.cxx index f57ba02eb6..e5db0780fa 100644 --- a/src/QABugs/QABugs_20.cxx +++ b/src/QABugs/QABugs_20.cxx @@ -2333,6 +2333,13 @@ static Standard_Integer OCC28784(Draw_Interpretor&, Standard_Integer argc, const return 0; } +static Standard_Integer OCC28829 (Draw_Interpretor&, Standard_Integer, const char**) +{ + // do something that causes FPE exception + std::cout << "sqrt(-1) = " << sqrt (-1.) << std::endl; + return 0; +} + void QABugs::Commands_20(Draw_Interpretor& theCommands) { const char *group = "QABugs"; @@ -2355,6 +2362,7 @@ void QABugs::Commands_20(Draw_Interpretor& theCommands) { theCommands.Add("OCC28389", "OCC28389", __FILE__, OCC28389, group); theCommands.Add("OCC28594", "OCC28594", __FILE__, OCC28594, group); theCommands.Add("OCC28784", "OCC28784 result shape", __FILE__, OCC28784, group); + theCommands.Add("OCC28829", "OCC28829: perform invalid FPE operation", __FILE__, OCC28829, group); return; } diff --git a/tests/bugs/fclasses/bug28829 b/tests/bugs/fclasses/bug28829 new file mode 100644 index 0000000000..74b2a60d5a --- /dev/null +++ b/tests/bugs/fclasses/bug28829 @@ -0,0 +1,15 @@ +# check that FPE signals can be both disabled and enabled + +pload QAcommands + +# start with enabled signals +dsetsignal 1 + +# first, disable +dsetsignal 0 +OCC28829 + +# then, enable +puts "REQUIRED OCC28829 All: Standard_NumericError" +dsetsignal 1 +catch {OCC28829}