>> On Mon, 13 Aug 2018 at 19:46, Duncan Roe <duncan_...@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 <truer...@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 > ```
If I understand correctly, `std::stod ()` uses cygwin1.dll's `strtod ()` for the conversion. `std::stod ()` is defined in /usr/lib/gcc/x86_64-pc-cygwin/7.3.0/include/c++/bits/basic_string.h L6388-. It calls `__gnu_cxx::__stoa ()` with pointer of `std::strtod ()`. ``` inline double stod(const string& __str, size_t* __idx = 0) { return __gnu_cxx::__stoa(&std::strtod, "stod", __str.c_str(), __idx); } ``` `__gnu_cxx::__stoa ()` is defined in /usr/lib/gcc/x86_64-pc-cygwin/7.3.0/include/c++/ext/string_conversions.h L51-. It calls the first parameter, `std::strtod ()`. `std::strtod ()` is cygwin1.dll's `strtod ()`. -- 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