This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: __builtin_isnanl() and invalid x87 80-bit floating point numbers


On 2017/5/16 0:43, Vincent Lefevre wrote:
On 2017-05-15 22:35:33 +0800, Liu Hao wrote:
Yeah but `printf()` from glibc doesn't think it is a NaN... From
your point of view, is this a glibc bug?

I think so. If I understand correctly, the output of floating-point
data in glibc is handled in stdio-common/printf_fp.c, which uses:

extern mp_size_t __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
                                             int *expt, int *is_neg,
                                             long double value);

The code is one of (not sure):
   sysdeps/i386/ldbl2mpn.c
   sysdeps/ieee754/ldbl-96/ldbl2mpn.c

In sysdeps/i386/ldbl2mpn.c only, there is a special case for
"pseudo zero" (no comments about the choice of the behavior,
though), which was added here:

commit 835abc5c0dfd1ba8aabeb52d46793b13702c708b
Author: Ulrich Drepper <drepper@redhat.com>
Date:   2007-06-08 02:50:59 +0000

     [BZ #4586]
2007-06-06 Jakub Jelinek <jakub@redhat.com>
             BZ #4586
             * sysdeps/i386/ldbl2mpn.c (__mpn_extract_long_double): Treat
             pseudo-zeros as zero.
             * sysdeps/x86_64/ldbl2mpn.c: New file.
             * sysdeps/ia64/ldbl2mpn.c: New file.

This corresponds to Bruno Haible's bug report:

   https://sourceware.org/bugzilla/show_bug.cgi?id=4586

(though this was for IA64). He said:

   Additionally, the printf results for pseudo-NaN and pseudo-Inf
   should better be "nan", because these numbers behave like NaNs
   in comparisons, as you can see from the program's output.

Not sure about the reason of the current choice.

It seems that MinGW-w64 is suffering from the same problem. I CC'd both. Looking forward to other people's opinion.

Reference: https://gcc.gnu.org/ml/gcc-help/2017-05/msg00123.html


--
Best regards,
LH_Mouse


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]