lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 657736a 1/5: Remove calls to std::fetestexcep


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 657736a 1/5: Remove calls to std::fetestexcept()
Date: Thu, 27 Apr 2017 11:54:07 -0400 (EDT)

branch: master
commit 657736ac8e675c3a75b432eabe0e5acee92bd51f
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Remove calls to std::fetestexcept()
    
    The removed code had hoped to query the FP control word, but instead
    queried the FP status word.
---
 fenv_lmi.cpp | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/fenv_lmi.cpp b/fenv_lmi.cpp
index 351400d..099192b 100644
--- a/fenv_lmi.cpp
+++ b/fenv_lmi.cpp
@@ -164,7 +164,12 @@ bool fenv_is_valid()
 #if defined LMI_X87
     return default_x87_control_word() == x87_control_word();
 #else  // !defined LMI_X87
-    return FE_TONEAREST == std::fegetround() && 0 == 
std::fetestexcept(FE_ALL_EXCEPT);
+    // SOMEDAY !! Consider using glibc's fegetexcept() here to test
+    // which exceptions are actually enabled. std::fetestexcept() is
+    // useless for this purpose because it tests the status word
+    // rather than the control word--see:
+    //   http://lists.nongnu.org/archive/html/lmi/2017-01/msg00024.html
+    return FE_TONEAREST == std::fegetround();
 #endif // !defined LMI_X87
 }
 
@@ -181,10 +186,15 @@ std::string fenv_explain_invalid_control_word()
         << "'.\n"
         ;
 #else  // !defined LMI_X87
+    // SOMEDAY !! Consider using glibc's fegetexcept() here to show
+    // which exceptions are actually enabled. std::fetestexcept() is
+    // useless for this purpose because it tests the status word
+    // rather than the control word--see:
+    //   http://lists.nongnu.org/archive/html/lmi/2017-01/msg00024.html
     oss
         << "The floating-point environment unexpectedly changed."
         << "\nThe rounding mode is " << std::fegetround()
-        << " and the exception bitmask is " << std::fetestexcept(FE_ALL_EXCEPT)
+//      << " and the exception bitmask is " << fegetexcept()
         << ".\n"
         ;
 #endif // !defined LMI_X87



reply via email to

[Prev in Thread] Current Thread [Next in Thread]