This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/13240] New: _Qp_itoq produces wrong value on Linux/SPARC64
- From: "bruno at clisp dot org" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: Fri, 30 Sep 2011 17:45:49 +0000
- Subject: [Bug libc/13240] New: _Qp_itoq produces wrong value on Linux/SPARC64
- Auto-submitted: auto-generated
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.