From: Bruno Haible Date: Tue, 16 Sep 2025 14:30:38 +0000 (+0200) Subject: strtof: Work around mingw bug with overflow. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=51aa7ef1381daf0226d4b958a728de3d9503485f;p=thirdparty%2Fgnulib.git strtof: Work around mingw bug with overflow. * lib/strtod.c (STRTOD): Recognize overflow. * modules/strtof (Depends-on): Add isinf. * modules/strtod (Depends-on): Likewise. * modules/strtold (Depends-on): Likewise. * doc/posix-functions/strtof.texi: Update mingw version. --- diff --git a/ChangeLog b/ChangeLog index 36dff72375..bbf3ce8741 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2025-09-16 Bruno Haible + + strtof: Work around mingw bug with overflow. + * lib/strtod.c (STRTOD): Recognize overflow. + * modules/strtof (Depends-on): Add isinf. + * modules/strtod (Depends-on): Likewise. + * modules/strtold (Depends-on): Likewise. + * doc/posix-functions/strtof.texi: Update mingw version. + 2025-09-16 Bruno Haible pagealign_alloc tests: Fix link error. diff --git a/doc/posix-functions/strtof.texi b/doc/posix-functions/strtof.texi index f1675d8087..9caa74d58d 100644 --- a/doc/posix-functions/strtof.texi +++ b/doc/posix-functions/strtof.texi @@ -28,7 +28,7 @@ macOS 10.6.6. @item This function fails to set @code{errno} upon overflow on some platforms: -mingw 5.0. +mingw 9.0. @item @c The term "underflow", as defined by ISO C23 § 7.12.1.(6), includes both diff --git a/lib/strtod.c b/lib/strtod.c index 1258753caf..73fe95ca03 100644 --- a/lib/strtod.c +++ b/lib/strtod.c @@ -492,6 +492,10 @@ STRTOD (const char *nptr, char **endptr) } end = e; } + /* If "1e50" was converted to Inf (overflow), errno needs to be + set. */ + else if (isinf (num)) + errno = ERANGE; } s = end; diff --git a/modules/strtod b/modules/strtod index 23ef6a5213..aaade58f7c 100644 --- a/modules/strtod +++ b/modules/strtod @@ -12,6 +12,7 @@ strtod-obsolete c-ctype [test $HAVE_STRTOD = 0 || test $REPLACE_STRTOD = 1] math-h [test $HAVE_STRTOD = 0 || test $REPLACE_STRTOD = 1] bool [test $HAVE_STRTOD = 0 || test $REPLACE_STRTOD = 1] +isinf [test $HAVE_STRTOD = 0 || test $REPLACE_STRTOD = 1] configure.ac: gl_FUNC_STRTOD diff --git a/modules/strtof b/modules/strtof index df3d795100..306e77a040 100644 --- a/modules/strtof +++ b/modules/strtof @@ -12,6 +12,7 @@ stdlib-h c-ctype [test $HAVE_STRTOF = 0 || test $REPLACE_STRTOF = 1] math-h [test $HAVE_STRTOF = 0 || test $REPLACE_STRTOF = 1] bool [test $HAVE_STRTOF = 0 || test $REPLACE_STRTOF = 1] +isinf [test $HAVE_STRTOF = 0 || test $REPLACE_STRTOF = 1] configure.ac: gl_FUNC_STRTOF diff --git a/modules/strtold b/modules/strtold index 4d8f6628b8..9cafe3f49a 100644 --- a/modules/strtold +++ b/modules/strtold @@ -13,6 +13,7 @@ stdlib-h c-ctype [test $HAVE_STRTOLD = 0 || test $REPLACE_STRTOLD = 1] math-h [test $HAVE_STRTOLD = 0 || test $REPLACE_STRTOLD = 1] bool [test $HAVE_STRTOLD = 0 || test $REPLACE_STRTOLD = 1] +isinf [test $HAVE_STRTOLD = 0 || test $REPLACE_STRTOLD = 1] strtod [{ test $HAVE_STRTOLD = 0 || test $REPLACE_STRTOLD = 1; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1] configure.ac: