NetBSD Problem Report #47834

From martin@duskware.de  Sat May 18 13:41:21 2013
Return-Path: <martin@duskware.de>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	by www.NetBSD.org (Postfix) with ESMTP id 0619C63F643
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 18 May 2013 13:41:21 +0000 (UTC)
From: martin@NetBSD.org
Reply-To: martin@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: 128 bit softfloat scalbnl broken
X-Send-Pr-Version: 3.95

>Number:         47834
>Category:       lib
>Synopsis:       128 bit softfloat scalbnl broken
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    martin
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat May 18 13:45:00 +0000 2013
>Closed-Date:    Mon Oct 07 07:48:02 +0000 2013
>Last-Modified:  Mon Oct 07 07:48:02 +0000 2013
>Originator:     Martin Husemann
>Release:        NetBSD 6.99.19
>Organization:
The NetBSD Foundation, Inc.
>Environment:
System: NetBSD thirdstage.duskware.de 6.99.19 NetBSD 6.99.19 (MODULAR) #92: Wed May 15 20:37:29 CEST 2013 martin@night-porter.duskware.de:/usr/src/sys/arch/sparc64/compile/MODULAR sparc64
Architecture: sparc64
Machine: sparc64
>Description:

Running the below test program (natively compiled on sparc64) reports
different, but all wrong numeric results depending on the optimization
level used.

With -O0 it says:
	0 (should be: 1.00085)

Letting the compiler pre-compute it with -O2 it says:
	2.0017 (should be: 1.00085)

>How-To-Repeat:
Natively compile this program (with -lm) on sparc64:

#include <math.h>
#include <stdio.h>

int main(int argc, char **argv)
{
	long double val = 1.00085;
	long double res = scalbnl(val, 1);

	printf("%Lg (should be: %Lg)\n", res, val);

	return 0;
}

>Fix:
n/a

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: port-sparc64-maintainer->martin
Responsible-Changed-By: martin@NetBSD.org
Responsible-Changed-When: Sat, 18 May 2013 13:51:16 +0000
Responsible-Changed-Why:
looking into it


From: matthew green <mrg@eterna.com.au>
To: gnats-bugs@NetBSD.org
Cc: port-sparc64-maintainer@netbsd.org, gnats-admin@netbsd.org,
    netbsd-bugs@netbsd.org
Subject: re: port-sparc64/47834: 128 bit softfloat scalbnl broken
Date: Sun, 19 May 2013 15:48:56 +1000

 your test program isn't entirely correct.

 > Running the below test program (natively compiled on sparc64) reports
 > different, but all wrong numeric results depending on the optimization
 > level used.
 > 
 > With -O0 it says:
 > 	0 (should be: 1.00085)

 this is bad.

 > Letting the compiler pre-compute it with -O2 it says:
 > 	2.0017 (should be: 1.00085)

 this result is correct.  FLT_RADIX is 2, and:

 DESCRIPTION
      The scalbn(), scalbnf(), and scalbnl() functions compute x * r^n, where r
      is the radix of the machine's floating point arithmetic, defined by the
      FLT_RADIX constant in <float.h>.  The rationale is efficiency; r^n is not

 ie, we have:  1.00085 * 2^1 => 2.0017.

 > >How-To-Repeat:
 > Natively compile this program (with -lm) on sparc64:
 > 
 > #include <math.h>
 > #include <stdio.h>
 > 
 > int main(int argc, char **argv)
 > {
 > 	long double val = 1.00085;
 > 	long double res = scalbnl(val, 1);
 > 
 > 	printf("%Lg (should be: %Lg)\n", res, val);
 > 
 > 	return 0;
 > }


 .mrg.

From: Martin Husemann <martin@duskware.de>
To: matthew green <mrg@eterna.com.au>
Cc: gnats-bugs@NetBSD.org, port-sparc64-maintainer@netbsd.org,
	gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: port-sparc64/47834: 128 bit softfloat scalbnl broken
Date: Sun, 19 May 2013 13:55:39 +0200

 On Sun, May 19, 2013 at 03:48:56PM +1000, matthew green wrote:
 > > Letting the compiler pre-compute it with -O2 it says:
 > > 	2.0017 (should be: 1.00085)
 > 
 > this result is correct.  FLT_RADIX is 2, and:

 Yeah, sorry, a previous version used 0 as exponent and I didn't fix the
 expected result when changing that. Which means gcc using gmp gets it right.

 Martin

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/47834 CVS commit: src/lib/libm/src
Date: Sun, 19 May 2013 20:50:02 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Sun May 19 20:50:02 UTC 2013

 Modified Files:
 	src/lib/libm/src: s_scalbnl.c

 Log Message:
 Try to fix bogus underflow test (obvious copy & pasto) - someone please
 review to make sure I got it right.
 This fixes PR 47834.


 To generate a diff of this commit:
 cvs rdiff -u -r1.7 -r1.8 src/lib/libm/src/s_scalbnl.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->feedback
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Mon, 07 Oct 2013 03:21:14 +0000
State-Changed-Why:
Is this fixed?


State-Changed-From-To: feedback->closed
State-Changed-By: martin@NetBSD.org
State-Changed-When: Mon, 07 Oct 2013 07:48:02 +0000
State-Changed-Why:
It works for me and noone responded to the review request.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(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.