From: Bruno Haible Date: Sun, 14 Jul 2024 16:38:16 +0000 (+0200) Subject: strtold: Work around major mingw bugs. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=3b644491256a1778e7a89ec6ae3a7dc54f86ec2c;p=gnulib.git strtold: Work around major mingw bugs. * lib/strtod.c (HAVE_UNDERLYING_STRTOD) [USE_LONG_DOUBLE]: Set to 0 on mingw versions before 10.0. * doc/posix-functions/strtold.texi: Mention the mingw bugs. --- diff --git a/ChangeLog b/ChangeLog index c7af30b4c2..9cd8f14566 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2024-07-14 Bruno Haible + + strtold: Work around major mingw bugs. + * lib/strtod.c (HAVE_UNDERLYING_STRTOD) [USE_LONG_DOUBLE]: Set to 0 on + mingw versions before 10.0. + * doc/posix-functions/strtold.texi: Mention the mingw bugs. + 2024-07-13 Bruno Haible stdlib: Support use of clang++ on Ubuntu. diff --git a/doc/posix-functions/strtold.texi b/doc/posix-functions/strtold.texi index 3fc1136ecb..5dbe158464 100644 --- a/doc/posix-functions/strtold.texi +++ b/doc/posix-functions/strtold.texi @@ -53,6 +53,10 @@ HP-UX 11.31/ia64. This function fails to set @code{errno} upon underflow on some platforms: @c https://cygwin.com/ml/cygwin/2019-12/msg00072.html Cygwin 2.9. + +@item +This function leaks memory on mingw 5.0 +and allocates an unbounded amount of stack on mingw 9.0. @end itemize Portability problems not fixed by Gnulib: diff --git a/lib/strtod.c b/lib/strtod.c index a545be09a4..e218a46f71 100644 --- a/lib/strtod.c +++ b/lib/strtod.c @@ -60,6 +60,13 @@ # elif STRTOLD_HAS_UNDERFLOW_BUG /* strtold would not set errno=ERANGE upon underflow. */ # define HAVE_UNDERLYING_STRTOD 0 +# elif defined __MINGW32__ && __MINGW64_VERSION_MAJOR < 10 + /* strtold is broken in mingw versions before 10.0: + - Up to mingw 5.0.x, it leaks memory at every invocation. + - Up to mingw 9.0.x, it allocates an unbounded amount of stack. + See + and . */ +# define HAVE_UNDERLYING_STRTOD 0 # else # define HAVE_UNDERLYING_STRTOD HAVE_STRTOLD # endif