During testing of corner cases in our software, we have discovered that strtod("1E-324", NULL) sets errno = EDOM. I think this is not correct. POSIX says this: """ These functions shall fail if: [ERANGE] The value to be returned would cause overflow or underflow. These functions may fail if: [EINVAL] No conversion could be performed. """ EDOM isn't even mentioned here. My test case is an underflow case, so ERANGE should be set. Also note that the analogous overflow case strtod("1E+324", NULL) does set ERANGE. For comparison, the BSD libc (Mac OS X) as well as HP-UX set ERANGE in both cases. The section in the glibc documentation "20.5.4 Error Reporting by Mathematical Functions" also appears to predict an ERANGE result. Bug #6776, while unrelated code, mentions a similar issue of EDOM/ ERANGE confusion.
Created attachment 5833 [details] Fix Thanks, here's a fix. 2011-07-05 Andreas Jaeger <aj@suse.de> [BZ#9696] * stdlib/strtod_l.c (round_and_return): Return ERANGE instead of EDOM. * stdlib/tst-strtod.c: Add testcase.
I checked in a patch.