summary refs log tree commit diff
path: root/math
diff options
context:
space:
mode:
Diffstat (limited to 'math')
-rw-r--r--math/Makefile3
-rw-r--r--math/bug-nextafter.c28
-rw-r--r--math/libm-test.inc5
3 files changed, 35 insertions, 1 deletions
diff --git a/math/Makefile b/math/Makefile
index d04269d298..b8624053a8 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -87,7 +87,8 @@ distribute += $(filter-out $(generated),$(long-m-yes:=.c) $(long-c-yes:=.c))
 
 # Rules for the test suite.
 tests = test-matherr test-fenv atest-exp atest-sincos atest-exp2 basic-test \
-	test-misc test-fpucw tst-definitions test-tgmath test-tgmath-ret
+	test-misc test-fpucw tst-definitions test-tgmath test-tgmath-ret \
+	bug-nextafter
 # We do the `long double' tests only if this data type is available and
 # distinct from `double'.
 test-longdouble-yes = test-ldouble test-ildoubl
diff --git a/math/bug-nextafter.c b/math/bug-nextafter.c
new file mode 100644
index 0000000000..8aa849df19
--- /dev/null
+++ b/math/bug-nextafter.c
@@ -0,0 +1,28 @@
+#include <math.h>
+#include <float.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+int
+main (void)
+{
+  int result = 0;
+
+  float i = INFINITY;
+  float m = FLT_MAX;
+  if (nextafterf (m, i) != i)
+    {
+      puts ("nextafterf failed");
+      ++result;
+    }
+
+  double di = INFINITY;
+  double dm = DBL_MAX;
+  if (nextafter (dm, di) != di)
+    {
+      puts ("nextafter failed");
+      ++result;
+    }
+
+  return result;
+}
diff --git a/math/libm-test.inc b/math/libm-test.inc
index 69752e00d5..38386c1ed5 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -3437,6 +3437,11 @@ nextafter_test (void)
   TEST_ff_f (nextafter, 1.1L, nan_value, nan_value);
   TEST_ff_f (nextafter, nan_value, nan_value, nan_value);
 
+  FLOAT fltmax = CHOOSE (LDBL_MAX, DBL_MAX, FLT_MAX,
+			 LDBL_MAX, DBL_MAX, FLT_MAX);
+  TEST_ff_f (nextafter, fltmax, plus_infty, plus_infty);
+  TEST_ff_f (nextafter, -fltmax, minus_infty, minus_infty);
+
 #ifdef TEST_LDOUBLE
   // XXX Enable once gcc is fixed.
   //TEST_ff_f (nextafter, 0x0.00000040000000000000p-16385L, -0.1L, 0x0.0000003ffffffff00000p-16385L);