summaryrefslogtreecommitdiff
path: root/m4/isinf.m4
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2015-02-20 18:09:47 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2015-02-20 18:10:46 -0800
commitbd38edc81714fc2679b02ef34033f9e15954d32f (patch)
tree239b8fb6edeb8bac9c3bb8065cd152101ce04fd4 /m4/isinf.m4
parent12d27cace7a75301f793527a57e5ae09ed73c4ba (diff)
downloadgnulib-bd38edc81714fc2679b02ef34033f9e15954d32f.tar.gz
printf, isinf, etc.: noncanonical != NaN
Do not require that isinf, printf, etc. treat noncanonical values as NaNs. Instead, require only that they do not crash. Problem reported by Joseph Myers in: https://sourceware.org/ml/libc-alpha/2015-02/msg00244.html * doc/posix-functions/dprintf.texi (dprintf): * doc/posix-functions/fprintf.texi (fprintf): * doc/posix-functions/isfinite.texi (isfinite): * doc/posix-functions/isinf.texi (isinf): * doc/posix-functions/isnan.texi (isnan): * doc/posix-functions/printf.texi (printf): * doc/posix-functions/snprintf.texi (snprintf): * doc/posix-functions/sprintf.texi (sprintf): * doc/posix-functions/vdprintf.texi (vdprintf): * doc/posix-functions/vfprintf.texi (vfprintf): * doc/posix-functions/vprintf.texi (vprintf): * doc/posix-functions/vsnprintf.texi (vsnprintf): * doc/posix-functions/vsprintf.texi (vsprintf): Document this. * m4/isfinite.m4 (gl_ISFINITEL_WORKS): * m4/isinf.m4 (gl_ISINFL_WORKS): * m4/isnanl.m4 (gl_FUNC_ISNANL_WORKS): * m4/printf.m4 (gl_PRINTF_INFINITE_LONG_DOUBLE): * tests/test-isfinite.c (test_isfinitel): * tests/test-isinf.c (test_isinfl): * tests/test-isnan.c (test_long_double): * tests/test-isnanl.h (main): * tests/test-snprintf-posix.h (test_function): * tests/test-sprintf-posix.h (test_function): * tests/test-vasnprintf-posix.c (test_function): * tests/test-vasprintf-posix.c (test_function): o Test only that noncanonical values do not cause crashes, not that they are treated as NaNs. In some cases this means a larger output buffer is needed.
Diffstat (limited to 'm4/isinf.m4')
-rw-r--r--m4/isinf.m439
1 files changed, 10 insertions, 29 deletions
diff --git a/m4/isinf.m4 b/m4/isinf.m4
index 4c5dd0bd71..b0a3da3301 100644
--- a/m4/isinf.m4
+++ b/m4/isinf.m4
@@ -1,4 +1,4 @@
-# isinf.m4 serial 10
+# isinf.m4 serial 11
dnl Copyright (C) 2007-2015 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -37,13 +37,8 @@ AC_DEFUN([gl_ISINF],
dnl Test whether isinf() works:
dnl 1) Whether it correctly returns false for LDBL_MAX.
-dnl 2) Whether on 'long double' recognizes all numbers which are neither
-dnl finite nor infinite. This test fails on OpenBSD/x86, but could also
-dnl fail e.g. on i686, x86_64, ia64, because of
-dnl - pseudo-denormals on x86_64,
-dnl - pseudo-zeroes, unnormalized numbers, and pseudo-denormals on i686,
-dnl - pseudo-NaN, pseudo-Infinity, pseudo-zeroes, unnormalized numbers, and
-dnl pseudo-denormals on ia64.
+dnl 2) Whether on 'long double' recognizes all canonical values which are
+dnl infinite.
AC_DEFUN([gl_ISINFL_WORKS],
[
AC_REQUIRE([AC_PROG_CC])
@@ -121,55 +116,41 @@ int main ()
if (isinf (x.value))
result |= 2;
}
- /* The isinf macro should recognize Pseudo-NaNs, Pseudo-Infinities,
- Pseudo-Zeroes, Unnormalized Numbers, and Pseudo-Denormals, as defined in
- Intel IA-64 Architecture Software Developer's Manual, Volume 1:
- Application Architecture.
- Table 5-2 "Floating-Point Register Encodings"
- Figure 5-6 "Memory to Floating-Point Register Data Translation"
- */
+ /* isinf should return something even for noncanonical values. */
{ /* Pseudo-NaN. */
static memory_long_double x =
{ LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) };
- if (isinf (x.value))
+ if (isinf (x.value) && !isinf (x.value))
result |= 4;
}
{ /* Pseudo-Infinity. */
static memory_long_double x =
{ LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) };
- if (isinf (x.value))
+ if (isinf (x.value) && !isinf (x.value))
result |= 8;
}
{ /* Pseudo-Zero. */
static memory_long_double x =
{ LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) };
- if (isinf (x.value))
+ if (isinf (x.value) && !isinf (x.value))
result |= 16;
}
{ /* Unnormalized number. */
static memory_long_double x =
{ LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) };
- if (isinf (x.value))
+ if (isinf (x.value) && !isinf (x.value))
result |= 32;
}
{ /* Pseudo-Denormal. */
static memory_long_double x =
{ LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) };
- if (isinf (x.value))
+ if (isinf (x.value) && !isinf (x.value))
result |= 64;
}
#endif
return result;
}]])], [gl_cv_func_isinfl_works=yes], [gl_cv_func_isinfl_works=no],
- [
- case "$host" in
- # Guess no on OpenBSD ia64, x86_64, i386.
- ia64-*-openbsd* | x86_64-*-openbsd* | i*86-*-openbsd*)
- gl_cv_func_isinfl_works="guessing no";;
- *)
- gl_cv_func_isinfl_works="guessing yes";;
- esac
- ])
+ [gl_cv_func_isinfl_works="guessing yes"])
])
])