public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/13240] New: _Qp_itoq produces wrong value on Linux/SPARC64
@ 2011-09-30 17:46 bruno at clisp dot org
  2011-09-30 17:47 ` [Bug libc/13240] " bruno at clisp dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: bruno at clisp dot org @ 2011-09-30 17:46 UTC (permalink / raw)
  To: glibc-bugs

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.


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-06-27 11:59 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-30 17:46 [Bug libc/13240] New: _Qp_itoq produces wrong value on Linux/SPARC64 bruno at clisp dot org
2011-09-30 17:47 ` [Bug libc/13240] " bruno at clisp dot org
2011-09-30 17:47 ` bruno at clisp dot org
2011-09-30 17:49 ` bruno at clisp dot org
2011-10-07 18:21 ` drepper.fsp at gmail dot com
2011-10-07 18:43 ` davem at davemloft dot net
2011-10-07 19:47 ` davem at davemloft dot net
2011-10-07 22:56 ` bruno at clisp dot org
2011-10-07 23:03 ` davem at davemloft dot net
2011-10-07 23:06 ` davem at davemloft dot net
2014-06-27 11:59 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).