NetBSD Problem Report #44189

From njoly@lanfeust.sis.pasteur.fr  Fri Dec  3 13:02:36 2010
Return-Path: <njoly@lanfeust.sis.pasteur.fr>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id CD4D463B95F
	for <gnats-bugs@gnats.NetBSD.org>; Fri,  3 Dec 2010 13:02:35 +0000 (UTC)
Message-Id: <20101203130225.7741FDC9BB@lanfeust.sis.pasteur.fr>
Date: Fri,  3 Dec 2010 14:02:25 +0100 (CET)
From: njoly@pasteur.fr
Reply-To: njoly@pasteur.fr
To: gnats-bugs@gnats.NetBSD.org
Subject: strtod(3) wrong results with "-0x"
X-Send-Pr-Version: 3.95

>Number:         44189
>Category:       lib
>Synopsis:       strtod(3) wrong results with "-0x"
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    lib-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Dec 03 13:05:01 +0000 2010
>Closed-Date:    Tue Mar 22 22:26:11 +0000 2011
>Last-Modified:  Tue Mar 22 22:30:02 +0000 2011
>Originator:     Nicolas Joly
>Release:        NetBSD 5.99.41
>Organization:
Institut Pasteur
>Environment:
System: NetBSD lanfeust.sis.pasteur.fr 5.99.41 NetBSD 5.99.41 (LANFEUST) #24: Fri Dec 3 12:01:14 CET 2010 njoly@lanfeust.sis.pasteur.fr:/local/src/NetBSD/obj.amd64/sys/arch/amd64/compile/LANFEUST amd64
Architecture: x86_64
Machine: amd64
>Description:
strtod(3) give bad result when trying to parse "-0x" string

njoly@lanfeust [~]> cat strtod.c 
#include <err.h>
#include <stdlib.h>

int main() {
  char *p, *str;
  double d;

  str = "-0x";
  d = strtod(str, &p);
  warnx("%f >>%s<<", d, p);

  return 0; }
njoly@lanfeust [~]> make strtod
cc -O2   -o strtod strtod.c 
njoly@lanfeust [~]> ./strtod 
strtod: 0.000000 >>-0x<<

This looks wrong, and would have expected instead:

strtod: -0.000000 >>x<<

>How-To-Repeat:
Try the provided testcase.
>Fix:

>Release-Note:

>Audit-Trail:
From: "Nicolas Joly" <njoly@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/44189 CVS commit: src
Date: Fri, 3 Dec 2010 13:11:51 +0000

 Module Name:	src
 Committed By:	njoly
 Date:		Fri Dec  3 13:11:50 UTC 2010

 Modified Files:
 	src/distrib/sets/lists/tests: mi
 	src/tests/lib/libc/stdlib: Makefile
 Added Files:
 	src/tests/lib/libc/stdlib: t_strtox.c

 Log Message:
 Add testcase for PR/44189: strtod(3) wrong results with "-0x".


 To generate a diff of this commit:
 cvs rdiff -u -r1.167 -r1.168 src/distrib/sets/lists/tests/mi
 cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/stdlib/Makefile
 cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/stdlib/t_strtox.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->closed
State-Changed-By: njoly@NetBSD.org
State-Changed-When: Tue, 22 Mar 2011 22:26:11 +0000
State-Changed-Why:
christos recent gdtoa import fixed it.


From: "Nicolas Joly" <njoly@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/44189 CVS commit: src/tests/lib/libc/stdlib
Date: Tue, 22 Mar 2011 22:29:18 +0000

 Module Name:	src
 Committed By:	njoly
 Date:		Tue Mar 22 22:29:18 UTC 2011

 Modified Files:
 	src/tests/lib/libc/stdlib: t_strtox.c

 Log Message:
 Test case from PR/44189 should not fail anymore.


 To generate a diff of this commit:
 cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/stdlib/t_strtox.c

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

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