From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2100) id 660D538618BD; Tue, 18 Aug 2020 01:18:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 660D538618BD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1597713526; bh=BmPeZ8OPN9tARz5B/DL9Dyaj8tuXVGI4Sabc0hsKhCU=; h=From:To:Subject:Date:From; b=n46usrEYQreBocJlOtuhcuQZo6AkDjNaG/xzZSWyIXvgBALh6xGMIUbG5UEfecnxI xeVpCpW53WCv+Ai1rbm1Wg/+aRQX7uhq2HY4nD0YzVC0Xx5Mmi2cAlEFyZ1UN598JX pQJ0nxCZ7yK0hmYKlBFqCJ7j3yJ2z98+MElkr7dI= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Giuliano Belinassi To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc(refs/users/giulianob/heads/autopar_rebase2)] libstdc++: Check _GLIBCXX_USE_C99_STDLIB for strtof and strtold X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/users/giulianob/heads/autopar_rebase2 X-Git-Oldrev: 2bca52013c047ccbc575e14bbab983b10c962651 X-Git-Newrev: c4a68ac16456ac8b04e6d0e2d21d174486516a39 Message-Id: <20200818011846.660D538618BD@sourceware.org> Date: Tue, 18 Aug 2020 01:18:46 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Aug 2020 01:18:46 -0000 https://gcc.gnu.org/g:c4a68ac16456ac8b04e6d0e2d21d174486516a39 commit c4a68ac16456ac8b04e6d0e2d21d174486516a39 Author: Jonathan Wakely Date: Thu Jul 30 20:55:56 2020 +0100 libstdc++: Check _GLIBCXX_USE_C99_STDLIB for strtof and strtold On broken systems we only have strtod, not strtof and strtold. Just use strtod for all types, even though that will produce incorrect results in some cases. Similarly, if _GLIBCXX_USE_C99_MATH is not defined then std::isinf won't be declared. Just refer to it unqualified, which should find the C library's isinf macro if that hasn't been #undef'd by . libstdc++-v3/ChangeLog: * src/c++17/floating_from_chars.cc (from_chars_impl): Use isinf unqualified. [!_GLIBCXX_USE_C99_STDLIB]: Use strtod for float and long double. Diff: --- libstdc++-v3/src/c++17/floating_from_chars.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/src/c++17/floating_from_chars.cc b/libstdc++-v3/src/c++17/floating_from_chars.cc index f1519e5c7b6..26b69a38521 100644 --- a/libstdc++-v3/src/c++17/floating_from_chars.cc +++ b/libstdc++-v3/src/c++17/floating_from_chars.cc @@ -300,12 +300,16 @@ namespace errno = 0; char* endptr; T tmpval; +#if _GLIBCXX_USE_C99_STDLIB if constexpr (is_same_v) tmpval = std::strtof(str, &endptr); - if constexpr (is_same_v) + else if constexpr (is_same_v) tmpval = std::strtod(str, &endptr); else if constexpr (is_same_v) tmpval = std::strtold(str, &endptr); +#else + tmpval = std::strtod(str, &endptr); +#endif const int conv_errno = std::__exchange(errno, save_errno); #if _GLIBCXX_USE_C99_FENV_TR1 @@ -319,7 +323,7 @@ namespace const ptrdiff_t n = endptr - str; if (conv_errno == ERANGE) [[unlikely]] { - if (std::isinf(tmpval)) // overflow + if (isinf(tmpval)) // overflow ec = errc::result_out_of_range; else // underflow (LWG 3081 wants to set value = tmpval here) ec = errc::result_out_of_range;