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/13240] New: _Qp_itoq produces wrong value on Linux/SPARC64


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

             Bug #: 13240
           Summary: _Qp_itoq produces wrong value on Linux/SPARC64
           Product: glibc
           Version: 2.8
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper.fsp@gmail.com
        ReportedBy: bruno@clisp.org
    Classification: Unclassified


_Qp_itoq is the function which converts a signed 'int' to a 'long double'.
It works incorrectly for negative values.

How to reproduce:
============================= bug.c ==============================
#include <stdio.h>
int a = 1;
int b = -1;
long double ll = 2.718281828459L;
volatile long double lla;
volatile long double llb;
int main ()
{
  lla += a * ll;
  llb += b * ll;
  printf ("lla=%Lg, llb=%Lg\n", lla, llb);
  return 0;
}
==================================================================
$ gcc -m64 -Wall bug.c
$ ./a.out
lla=2.71828, llb=1.16749e+10

Expected result:
$ ./a.out
lla=2.71828, llb=-2.71828

The fix is in the _Qp_itoq function, as can be seen here:
============================= fix.c ==============================
void _Qp_itoq(long double *c, const int a)
{
  *c = (double) a;
}
==================================================================
$ gcc -m64 -Wall bug.c fix.c
$ ./a.out
lla=2.71828, llb=-2.71828

The source code of this function appears to be in file
glibc/sysdeps/sparc/sparc64/soft-fp/qp_itoq.c

-- 
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]