X-Recipient: archive-cygwin@delorie.com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:date:message-id:to:subject:from:in-reply-to
	:references:mime-version:content-type:content-transfer-encoding;
	 q=dns; s=default; b=TNbTrd+HBjoxBHXp4MCTlSlWp8vtMgDD6WAmJDESvda
	xD9mSlT1Zc/mVC+C9vWzZDW4jAs+7f59krtL1r5JQmD6xE+i42ehy7ht8K/PJz7g
	vyRMbiTxdn27E8IhQKldZWbQrEqh36/b7r+EZVqjCl0hwxX2aj62Yh+BfsPsWs9Q
	=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:date:message-id:to:subject:from:in-reply-to
	:references:mime-version:content-type:content-transfer-encoding;
	 s=default; bh=KFG+P8oYf5u5MBiAMTFNHId0zcM=; b=gSXTmpG9wfaO3Yz5H
	ZFy3RK7JwbVXglmb5FJa6jKrs6/RXisV7zHxdNeLtsgiQRQGjVV/PapJYQiceV7p
	p2ZYgXNw0vmDlJjEdOCrXrGNFaKCCm6MIDCVzCGpBozuktofHhOJ7CiSZQHdD7l+
	KtJZu947Uzz3sqgpgPHJ3oD8+o=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 spammy=H*x:version, H*UA:version, Hx-languages-length:1261, H*Ad:D*jp
X-HELO: msc13.plala.or.jp
Date: Tue, 14 Aug 2018 10:09:52 +0900 (JST)
Message-Id: <20180814.100952.1684125661222835312.trueroad@trueroad.jp>
To: cygwin@cygwin.com
Subject: Re: `std::stod ("nan")` returns negative NaN
From: Masamichi Hosoda <trueroad@trueroad.jp>
In-Reply-To: <CANnLRdii8mX71D936AhhEYm+S0s4gS5RGgpPhV_rB6=kzmXKsw@mail.gmail.com>
References: <20180813234603.GA2310@dimstar.local.net>	<20180813234603_dot_GA2310_at_dimstar_dot_local_dot_net>	<CANnLRdii8mX71D936AhhEYm+S0s4gS5RGgpPhV_rB6=kzmXKsw@mail.gmail.com>
Mime-Version: 1.0
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-VirusScan: Outbound; mvir-ac13; Tue, 14 Aug 2018 10:09:55 +0900

> On Mon, 13 Aug 2018 at 19:46, Duncan Roe <duncan_roe@optusnet.com.au> wrote:
>>
>> On Mon, Aug 13, 2018 at 12:52:48PM -0400, Stephen John Smoogen wrote:
>> > On Mon, 13 Aug 2018 at 11:16, Masamichi Hosoda <trueroad@trueroad.jp> wrote:
>> [...]
>> > On Fedora 27 with 7.3.1 it gives
>> > ```
>> > stod ("nan") = nan
>> > stod ("-nan") = nan
>> > quiet_NaN () = nan
>> > ```
>> [...]
> 
> I tested a compile on Windows Subsystem for Linux Ubuntu 18.04 which
> had gcc 7.3.0. The output was the same as everything but Cygwin. At
> this point it is time to pull through the gdb debugger and try to
> figure out where it is coming from.

I suspect `cygwin1.dll`'s `strtod ()` etc.
Here's a code.

```
/* gcc foobar.c */

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

int main (void)
{
  printf ("strtod (\"nan\", NULL) = %f\n", strtod ("nan", NULL));
  printf ("strtod (\"-nan\", NULL) = %f\n", strtod ("-nan", NULL));
  printf ("nan (\"\") = %f\n", nan (""));

  return 0;
}
```

Cygwin 2.10.0 64 bit with gcc 7.3.0
```
strtod ("nan", NULL) = -nan
strtod ("-nan", NULL) = nan
nan ("") = nan
```

Ubuntu 16.04 LTS 64 bit with gcc 5.4.0
```
strtod ("nan", NULL) = nan
strtod ("-nan", NULL) = nan
nan ("") = nan
```

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

