about summary refs log tree commit diff
path: root/math/bug-nextafter.c
diff options
context:
space:
mode:
Diffstat (limited to 'math/bug-nextafter.c')
-rw-r--r--math/bug-nextafter.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/math/bug-nextafter.c b/math/bug-nextafter.c
index 8aa849df19..015c32dd93 100644
--- a/math/bug-nextafter.c
+++ b/math/bug-nextafter.c
@@ -1,3 +1,4 @@
+#include <fenv.h>
 #include <math.h>
 #include <float.h>
 #include <stdlib.h>
@@ -10,19 +11,53 @@ main (void)
 
   float i = INFINITY;
   float m = FLT_MAX;
+  feclearexcept (FE_ALL_EXCEPT);
   if (nextafterf (m, i) != i)
     {
-      puts ("nextafterf failed");
+      puts ("nextafterf+ failed");
+      ++result;
+    }
+  if (fetestexcept (FE_OVERFLOW) != 0)
+    {
+      puts ("nextafterf+ did not overflow");
+      ++result;
+    }
+  feclearexcept (FE_ALL_EXCEPT);
+  if (nextafterf (-m, -i) != -i)
+    {
+      puts ("nextafterf- failed");
+      ++result;
+    }
+  if (fetestexcept (FE_OVERFLOW) != 0)
+    {
+      puts ("nextafterf- did not overflow");
       ++result;
     }
 
   double di = INFINITY;
   double dm = DBL_MAX;
+  feclearexcept (FE_ALL_EXCEPT);
   if (nextafter (dm, di) != di)
     {
+      puts ("nextafter+ failed");
+      ++result;
+    }
+  if (fetestexcept (FE_OVERFLOW) != 0)
+    {
+      puts ("nextafter+ did not overflow");
+      ++result;
+    }
+  feclearexcept (FE_ALL_EXCEPT);
+  if (nextafter (-dm, -di) != -di)
+    {
       puts ("nextafter failed");
       ++result;
     }
+  if (fetestexcept (FE_OVERFLOW) != 0)
+    {
+      puts ("nextafter- did not overflow");
+      ++result;
+    }
 
   return result;
 }