From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 87A513858C5F; Mon, 24 Jul 2023 20:04:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 87A513858C5F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1690229060; bh=5QRzsmeTFFR6c0piscp8bT5WwnM62s08lzq1PyIl0aM=; h=From:To:Subject:Date:From; b=Wye3CM5DreYn+7CTXWlrIAwqZRWqeuG7KUNP3SdQS/EqGlnsVvWKFTt5CzTG01h/q Y5v4xaWUqi9B1f5ZoJgxzhSU/JiUIzAlFQAtWlyi2BoUnr0uCDe9j4uOPUFSEo0p8U Q2TmgnaQEhBSTNPHz7w/hldVfoy0YK31J9Os4zOE= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r14-2753] libstdc++; Do not use strtold for hppa-hpux [PR110653] X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: be16bb885ef141dc497f6e7358ac82e9bed4f34d X-Git-Newrev: 31c3b67dfc6e67773d13260bc38b833663698b74 Message-Id: <20230724200420.87A513858C5F@sourceware.org> Date: Mon, 24 Jul 2023 20:04:20 +0000 (GMT) List-Id: https://gcc.gnu.org/g:31c3b67dfc6e67773d13260bc38b833663698b74 commit r14-2753-g31c3b67dfc6e67773d13260bc38b833663698b74 Author: Jonathan Wakely Date: Mon Jul 24 11:45:43 2023 +0100 libstdc++; Do not use strtold for hppa-hpux [PR110653] When I switched std::stold to depend on HAVE_STRTOLD that enabled it for hppa-hpux which defines HAVE_BROKEN_STRTOLD. Add a check for that macro so that we don't use strtold, and fall through to the check for double and long double having the same representation. That should mean we define a conforming std::stold in terms of std::stod, instead of trying to use the broken strtold. Also fix a logic error in the fallback definition of std::stod, which should not treat zero as a subnormal number. libstdc++-v3/ChangeLog: PR libstdc++/110653 * include/bits/basic_string.h [!HAVE_STOF] (stof): Do not throw an exception for zero result. [HAVE_BROKEN_STRTOLD] (stold): Do not use strtold. Diff: --- libstdc++-v3/include/bits/basic_string.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h index e4cb9846025..170a43664c9 100644 --- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -4148,7 +4148,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 stod(const string& __str, size_t* __idx = 0) { return __gnu_cxx::__stoa(&std::strtod, "stod", __str.c_str(), __idx); } -#if _GLIBCXX_USE_C99_STDLIB || _GLIBCXX_HAVE_STRTOF +#if _GLIBCXX_HAVE_STRTOF // NB: strtof vs strtod. inline float stof(const string& __str, size_t* __idx = 0) @@ -4158,7 +4158,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 stof(const string& __str, size_t* __idx = 0) { double __d = std::stod(__str, __idx); - if (__builtin_isfinite(__d)) + if (__builtin_isfinite(__d) && __d != 0.0) { double __abs_d = __builtin_fabs(__d); if (__abs_d < __FLT_MIN__ || __abs_d > __FLT_MAX__) @@ -4171,7 +4171,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 } #endif -#if _GLIBCXX_USE_C99_STDLIB || _GLIBCXX_HAVE_STRTOLD +#if _GLIBCXX_HAVE_STRTOLD && ! _GLIBCXX_HAVE_BROKEN_STRTOLD inline long double stold(const string& __str, size_t* __idx = 0) { return __gnu_cxx::__stoa(&std::strtold, "stold", __str.c_str(), __idx); }