+2024-07-23 Bruno Haible <bruno@clisp.org>
+
+ strtof: Revisit underflow behaviour.
+ * doc/posix-functions/strtof.texi: Mention the macOS bug. Mention the
+ mingw overflow bug. Mention the underflow bugs on Cygwin 2.9 and mingw.
+ Mention that gradual underflow does not count as an error on Cygwin 2.9,
+ mingw, MSVC.
+ * m4/strtof.m4 (gl_FUNC_STRTOF): Test against the mingw overflow bug.
+
2024-07-23 Bruno Haible <bruno@clisp.org>
strtof, strtod, strtold: Fix underflow behaviour of system function.
@item
This function fails to parse @samp{NaN()} on some platforms:
-glibc-2.5, FreeBSD 6.2.
+glibc 2.5, FreeBSD 6.2.
+
+@item
+This function misparses @samp{nan(} on some platforms:
+macOS 10.6.6.
+
+@item
+This function fails to set @code{errno} upon overflow on some platforms:
+mingw 5.0.
+
+@item
+@c The term "underflow", as defined by ISO C23 ยง 7.12.1.(6), includes both
+@c "gradual underflow" (result is a denormalized number) and "flush-to-zero
+@c underflow" (result is zero).
+This function fails to set @code{errno} upon underflow on some platforms:
+Cygwin 2.9, mingw 5.0.
@end itemize
Portability problems not fixed by Gnulib:
platforms:
Mac OS X 10.5, FreeBSD 6.2, NetBSD 5.0, Cygwin, mingw, MSVC 14.
+@item
+This function fails to set @code{errno} upon gradual underflow (resulting
+in a denormalized number) on some platforms:
+MSVC 14.
+
@item
The replacement function does not always return correctly rounded results.
@end itemize
# strtof.m4
-# serial 3
+# serial 4
dnl Copyright (C) 2002-2003, 2006-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
if (value != HUGE_VAL || term != (string + 3) || errno)
result |= 8;
}
+ {
+ /* In mingw 5.0 without __USE_MINGW_ANSI_STDIO and __USE_MINGW_STRTOX,
+ strtof does not set errno upon overflow. */
+ const char *string = "1e50";
+ char *term;
+ float value;
+ errno = 0;
+ value = strtof (string, &term);
+ if (value != HUGE_VAL || term != (string + 4) || errno != ERANGE)
+ result |= 8;
+ }
{
/* glibc 2.7 and cygwin 1.5.24 misparse "nan()". */
const char *string = "nan()";
result |= 16;
}
{
- /* darwin 10.6.1 misparses "nan(". */
+ /* Darwin 10.6.1 (macOS 10.6.6) misparses "nan(". */
const char *string = "nan(";
char *term;
float value = strtof (string, &term);