[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: printf-safe checks of invalid long double values
From: |
Ondřej Bílka |
Subject: |
Re: printf-safe checks of invalid long double values |
Date: |
Fri, 28 Nov 2014 14:32:21 +0100 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
On Thu, Nov 27, 2014 at 08:37:59PM -0800, Paul Eggert wrote:
> Pádraig Brady wrote:
> > Are these checks backed up by corresponding replacement code?
> > Are these checks correct?
> > Why has glibc not been updated in the 7 years since the checks were added?
>
> As I recall, this comes from an old dispute about what glibc should
> do when asked to print floating-point bit-patterns that cannot be
> generated by the machine's floating-point operations. This has
> undefined behavior in glibc (and POSIX allows this), but undefined
> behavior can be catastrophic in programs like 'od' which will crash
> when asked to print arbitrary data as if it were floating-point. So
> coreutils insists on a substitute for printf for this situation.
>
> See the thread starting here:
>
> http://lists.gnu.org/archive/html/bug-gnulib/2007-06/msg00046.html
>From bug ticket pseudo zero patterns were fixed by
2007-06-06 Jakub Jelinek <address@hidden>
[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.
You could write patch to handle pseudo-infinity as well.