NetBSD Problem Report #47536
From martin@aprisoft.de Wed Feb 6 14:32:52 2013
Return-Path: <martin@aprisoft.de>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
by www.NetBSD.org (Postfix) with ESMTP id 38E8D63E8B1
for <gnats-bugs@gnats.NetBSD.org>; Wed, 6 Feb 2013 14:32:52 +0000 (UTC)
Message-Id: <20130206143245.452CAED0E4C@emmas.aprisoft.de>
Date: Wed, 6 Feb 2013 15:32:45 +0100 (CET)
From: martin@NetBSD.org
Reply-To: martin@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: printf conversion fails for long double on sparc64
X-Send-Pr-Version: 3.95
>Number: 47536
>Category: port-sparc64
>Synopsis: printf conversion fails for long double on sparc64
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: martin
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Feb 06 14:35:01 +0000 2013
>Closed-Date: Sat Jul 13 20:14:06 +0000 2013
>Last-Modified: Sat Jul 13 20:14:06 +0000 2013
>Originator: Martin Husemann
>Release: NetBSD 6.99.16
>Organization:
The NetBSD Foundation, Inc.
>Environment:
System: NetBSD whoever-brings-the-night.aprisoft.de 6.99.16 NetBSD 6.99.16 (WHOEVER) #20: Mon Feb 4 12:20:15 CET 2013 martin@emmas.aprisoft.de:/usr/src/sys/arch/sparc64/compile/WHOEVER sparc64
Architecture: sparc64
Machine: sparc64
>Description:
This is a test program by Edward Berner posted to the Fossil users list:
#include <stdio.h>
int
main (int argc, char *argv[])
{
long long n;
long double ld;
n = 2147483648LL;
ld = n;
printf (" n = %lld\n", n);
printf ("ld = %0.17Lg\n", ld);
return 0;
}
When run on sparc64 it prints:
n = 2147483648
ld = 0
>How-To-Repeat:
s/a
>Fix:
n/a
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: port-sparc64-maintainer->martin
Responsible-Changed-By: martin@NetBSD.org
Responsible-Changed-When: Wed, 06 Feb 2013 14:37:14 +0000
Responsible-Changed-Why:
Take
From: David Laight <david@l8s.co.uk>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: port-sparc64/47536: printf conversion fails for long double on sparc64
Date: Wed, 6 Feb 2013 21:36:47 +0000
On Wed, Feb 06, 2013 at 02:35:01PM +0000, martin@NetBSD.org wrote:
> >Number: 47536
> >Category: port-sparc64
> >Synopsis: printf conversion fails for long double on sparc64
...
> long long n;
> long double ld;
>
> n = 2147483648LL;
> ld = n;
> printf (" n = %lld\n", n);
> printf ("ld = %0.17Lg\n", ld);
...
> When run on sparc64 it prints:
> n = 2147483648
> ld = 0
Is that a printf() problem or a 'long long' to 'long double'
convertion problem?
David
--
David Laight: david@l8s.co.uk
From: Jukka Ruohonen <jruohonen@iki.fi>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: port-sparc64/47536: printf conversion fails for long double on sparc64
Date: Thu, 7 Feb 2013 17:12:27 +0200
On Wed, Feb 06, 2013 at 02:35:01PM +0000, martin@NetBSD.org wrote:
> This is a test program by Edward Berner posted to the Fossil users list:
>
> #include <stdio.h>
>
> int
> main (int argc, char *argv[])
> {
> long long n;
> long double ld;
>
> n = 2147483648LL;
> ld = n;
> printf (" n = %lld\n", n);
> printf ("ld = %0.17Lg\n", ld);
>
> return 0;
> }
Looks like a test case? Perhaps if augmented with some other comparable
cases, similar problems in other architectures could be also revealed
(cf. e.g. the innocent PR lib/22019; lib/32951; lib/44113).
- Jukka.
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: port-sparc64/47536: printf conversion fails for long double on sparc64
Date: Wed, 13 Feb 2013 08:30:10 +0100
[forwarded to gnats to update the ticket]
Martin
---8<---
From: christos@astron.com (Christos Zoulas)
Subject: Re: port-sparc64/47536: printf conversion fails for long double on sparc64
Date: Wed, 13 Feb 2013 03:31:17 +0000 (UTC)
In article <20130207154009.746AE63EF83@www.NetBSD.org>,
Jukka Ruohonen <gnats-bugs@NetBSD.org> wrote:
>The following reply was made to PR port-sparc64/47536; it has been noted
>by GNATS.
>
>From: Jukka Ruohonen <jruohonen@iki.fi>
>To: gnats-bugs@NetBSD.org
>Cc:
>Subject: Re: port-sparc64/47536: printf conversion fails for long double
>on sparc64
>Date: Thu, 7 Feb 2013 17:12:27 +0200
>
> On Wed, Feb 06, 2013 at 02:35:01PM +0000, martin@NetBSD.org wrote:
> > This is a test program by Edward Berner posted to the Fossil users list:
> >
> > #include <stdio.h>
> >
> > int
> > main (int argc, char *argv[])
> > {
> > long long n;
> > long double ld;
> >
> > n = 2147483648LL;
> > ld = n;
> > printf (" n = %lld\n", n);
> > printf ("ld = %0.17Lg\n", ld);
> >
> > return 0;
> > }
>
> Looks like a test case? Perhaps if augmented with some other comparable
> cases, similar problems in other architectures could be also revealed
> (cf. e.g. the innocent PR lib/22019; lib/32951; lib/44113).
The sign bit is not set in the long long -> long double conversion.
Printf is not at fault.
#include <stdio.h>
int
main(int argc, char *argv[])
{
union {
long double ld;
long long n[2];
} u;
u.ld = 2147483648LL;
#ifdef __sparc64__
u.n[1] = 0x0000000080000000llu;
#endif
printf("%zu, %zu\n", sizeof(u.ld), sizeof(u.n));
printf(" u.n %llx %llx\n", u.n[0], u.n[1]);
printf("u.ld %0.17Lg\n", u.ld);
return 0;
}
christos
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: port-sparc64/47536: printf conversion fails for long double on sparc64
Date: Wed, 13 Feb 2013 09:53:00 +0100
The gcc generated code for the call site is correct. For the original test
program it placess the format string pointer in %o0, and the correct long
double value (pre generated at compile time) in %o2 and %o3.
Sounds like a va_list problem with the padding (%o1 being skipped).
Martin
From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/47536 CVS commit: src/sys/arch/sparc/include
Date: Thu, 14 Feb 2013 09:34:46 +0000
Module Name: src
Committed By: martin
Date: Thu Feb 14 09:34:46 UTC 2013
Modified Files:
src/sys/arch/sparc/include: ieee.h
Log Message:
We have an implicit 1 MSB bit in the mantissa. Pointed out by Matt Thomas.
Fixes PR port-sparc64/47536.
To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/sparc/include/ieee.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->pending-pullups
State-Changed-By: martin@NetBSD.org
State-Changed-When: Thu, 14 Feb 2013 09:35:50 +0000
State-Changed-Why:
Fixed in current, needs pullup.
From: "Julian Coleman" <jdc@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/47536 CVS commit: [netbsd-6] src/sys/arch/sparc/include
Date: Thu, 14 Feb 2013 22:12:11 +0000
Module Name: src
Committed By: jdc
Date: Thu Feb 14 22:12:10 UTC 2013
Modified Files:
src/sys/arch/sparc/include [netbsd-6]: ieee.h
Log Message:
Pull up revision 1.15 (requested by martin in ticket #821).
We have an implicit 1 MSB bit in the mantissa. Pointed out by Matt Thomas.
Fixes PR port-sparc64/47536.
To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.14.8.1 src/sys/arch/sparc/include/ieee.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: pending-pullups->closed
State-Changed-By: martin@NetBSD.org
State-Changed-When: Sat, 13 Jul 2013 20:14:06 +0000
State-Changed-Why:
Pullups done
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.