diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2015-02-20 18:09:47 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2015-02-20 18:10:46 -0800 |
commit | bd38edc81714fc2679b02ef34033f9e15954d32f (patch) | |
tree | 239b8fb6edeb8bac9c3bb8065cd152101ce04fd4 /m4/isfinite.m4 | |
parent | 12d27cace7a75301f793527a57e5ae09ed73c4ba (diff) | |
download | gnulib-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/isfinite.m4')
-rw-r--r-- | m4/isfinite.m4 | 36 |
1 files changed, 10 insertions, 26 deletions
diff --git a/m4/isfinite.m4 b/m4/isfinite.m4 index e086ca72cb..00d7e8042e 100644 --- a/m4/isfinite.m4 +++ b/m4/isfinite.m4 @@ -1,4 +1,4 @@ -# isfinite.m4 serial 14 +# isfinite.m4 serial 15 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, @@ -34,13 +34,8 @@ AC_DEFUN([gl_ISFINITE], AC_SUBST([ISFINITE_LIBM]) ]) -dnl Test whether isfinite() on 'long double' recognizes all numbers which are -dnl neither finite nor infinite. This test fails e.g. on i686, x86_64, ia64, -dnl 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 Test whether isfinite() on 'long double' recognizes all canonical values +dnl which are neither finite nor infinite. AC_DEFUN([gl_ISFINITEL_WORKS], [ AC_REQUIRE([AC_PROG_CC]) @@ -114,52 +109,41 @@ int main () if (isfinite (x.value)) result |= 2; } - /* The isfinite 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" - */ + /* isfinite should return something even for noncanonical values. */ { /* Pseudo-NaN. */ static memory_long_double x = { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) }; - if (isfinite (x.value)) + if (isfinite (x.value) && !isfinite (x.value)) result |= 4; } { /* Pseudo-Infinity. */ static memory_long_double x = { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) }; - if (isfinite (x.value)) + if (isfinite (x.value) && !isfinite (x.value)) result |= 8; } { /* Pseudo-Zero. */ static memory_long_double x = { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) }; - if (isfinite (x.value)) + if (isfinite (x.value) && !isfinite (x.value)) result |= 16; } { /* Unnormalized number. */ static memory_long_double x = { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) }; - if (isfinite (x.value)) + if (isfinite (x.value) && !isfinite (x.value)) result |= 32; } { /* Pseudo-Denormal. */ static memory_long_double x = { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) }; - if (isfinite (x.value)) + if (isfinite (x.value) && !isfinite (x.value)) result |= 64; } #endif return result; }]])], [gl_cv_func_isfinitel_works=yes], [gl_cv_func_isfinitel_works=no], - [case "$host_cpu" in - # Guess no on ia64, x86_64, i386. - ia64 | x86_64 | i*86) gl_cv_func_isfinitel_works="guessing no";; - *) gl_cv_func_isfinitel_works="guessing yes";; - esac - ]) + [gl_cv_func_isfinitel_works="guessing yes"]) ]) ]) |