This is the mail archive of the glibc-bugs@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]

[Bug libc/14551] New: strtold overflow handling for IBM long double


http://sourceware.org/bugzilla/show_bug.cgi?id=14551

             Bug #: 14551
           Summary: strtold overflow handling for IBM long double
           Product: glibc
           Version: 2.16
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: unassigned@sourceware.org
        ReportedBy: jsm28@gcc.gnu.org
                CC: drepper.fsp@gmail.com
    Classification: Unclassified
              Host: powerpc*-linux*


The core strtold code treats IBM long double as an IEEE type with a fixed
mantissa precision of 106 bits.  It's then
sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c that actually encodes the result in long
double.

Where the value overflows for IBM long double (because of the requirement that
the two parts, added together in round-to-nearest mode, equal the top part of
the long double) but not for the 106-bit IEEE type, the mpn2ldbl code generates
an invalid long double value.  It should generate the appropriate overflowed
result (typically an infinity, but properly depending on rounding mode), set
errno to ERANGE and raise the overflow exception.  Testcase:

#include <stdio.h>
#include <stdlib.h>

int
main (void)
{
  union { long double ld; double d[2]; } x;
  x.ld = strtold ("0x1.fffffffffffff8p+1023", NULL);
  printf ("%a %a\n", x.d[0], x.d[1]);
  return 0;
}

This prints:

inf -0x1p+970

That's not a valid infinity (and so causes problems such as not comparing equal
to a proper infinity); the least significant part of an infinity must be +0 or
-0 as per GCC's libgcc/config/rs6000/ibm-ldouble-format.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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