From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id CB3823858C78; Wed, 19 Jul 2023 23:31:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CB3823858C78 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689809493; bh=EcMx7GOoCQqh5tLR+vTu9B46849SB3IBsRFy9GLerJ0=; h=From:To:Subject:Date:From; b=ll++NOJxqpRl7GPNtCW/OSv7A0Sy8nmhEWCDxR/Rs06WojhxfLv1sTQIFBEGpKujh aVyDYWDmAeN33SfMqEYWhcViKkykuVWG04bDrOgt8UpYRAnhSpw2KDJqw+ZsUue9Ng x978QRDaUEGh6cXgwGTehkP60ldx3n9/7fK60aA8= 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 r13-7593] libstdc++: Fix preprocessor conditions for std::from_chars [PR109921] X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/releases/gcc-13 X-Git-Oldrev: 92f6240baf80f998ca6c1408c3ee09d5d2ae68d7 X-Git-Newrev: cd2f934bb09c04e62beb8eb5421467184598983b Message-Id: <20230719233133.CB3823858C78@sourceware.org> Date: Wed, 19 Jul 2023 23:31:33 +0000 (GMT) List-Id: https://gcc.gnu.org/g:cd2f934bb09c04e62beb8eb5421467184598983b commit r13-7593-gcd2f934bb09c04e62beb8eb5421467184598983b Author: Jonathan Wakely Date: Thu May 25 10:32:33 2023 +0100 libstdc++: Fix preprocessor conditions for std::from_chars [PR109921] We use the from_chars_strtod function with __strtof128 to read a _Float128 value, but from_chars_strtod is not defined unless uselocale is available. This can lead to compilation failures for some targets, because we try to define the _Float128 overload in terms of a non-existing from_chars_strtod function. Only try to use __strtof128 if uselocale is available and therefore we can use the from_chars_strtod function template. This is a simpler change than r14-1431-g7037e7b6e4ac41 on trunk, because that caused unwanted ABI regressions (PR libstdc++/110077). libstdc++-v3/ChangeLog: PR libstdc++/109921 * src/c++17/floating_from_chars.cc (USE_STRTOF128_FOR_FROM_CHARS): Only define when USE_STRTOD_FOR_FROM_CHARS is also defined. (USE_STRTOD_FOR_FROM_CHARS): Do not undefine when long double is binary64. (from_chars(const char*, const char*, double&, chars_format)): Check __LDBL_MANT_DIG__ == __DBL_MANT_DIG__ here. Diff: --- libstdc++-v3/src/c++17/floating_from_chars.cc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/libstdc++-v3/src/c++17/floating_from_chars.cc b/libstdc++-v3/src/c++17/floating_from_chars.cc index 78b9d92cdc0..b3061bdca01 100644 --- a/libstdc++-v3/src/c++17/floating_from_chars.cc +++ b/libstdc++-v3/src/c++17/floating_from_chars.cc @@ -64,7 +64,7 @@ // strtold for __ieee128 extern "C" __ieee128 __strtoieee128(const char*, char**); #elif __FLT128_MANT_DIG__ == 113 && __LDBL_MANT_DIG__ != 113 \ - && defined(__GLIBC_PREREQ) + && defined(__GLIBC_PREREQ) && defined(USE_STRTOD_FOR_FROM_CHARS) #define USE_STRTOF128_FOR_FROM_CHARS 1 extern "C" _Float128 __strtof128(const char*, char**) __asm ("strtof128") @@ -77,10 +77,6 @@ extern "C" _Float128 __strtof128(const char*, char**) #if _GLIBCXX_FLOAT_IS_IEEE_BINARY32 && _GLIBCXX_DOUBLE_IS_IEEE_BINARY64 \ && __SIZE_WIDTH__ >= 32 # define USE_LIB_FAST_FLOAT 1 -# if __LDBL_MANT_DIG__ == __DBL_MANT_DIG__ -// No need to use strtold. -# undef USE_STRTOD_FOR_FROM_CHARS -# endif #endif #if USE_LIB_FAST_FLOAT @@ -1211,7 +1207,7 @@ from_chars_result from_chars(const char* first, const char* last, long double& value, chars_format fmt) noexcept { -#if ! USE_STRTOD_FOR_FROM_CHARS +#if __LDBL_MANT_DIG__ == __DBL_MANT_DIG__ || !defined USE_STRTOD_FOR_FROM_CHARS // Either long double is the same as double, or we can't use strtold. // In the latter case, this might give an incorrect result (e.g. values // out of range of double give an error, even if they fit in long double). @@ -1280,6 +1276,7 @@ _ZSt10from_charsPKcS0_RDF128_St12chars_format(const char* first, chars_format fmt) noexcept __attribute__((alias ("_ZSt10from_charsPKcS0_Ru9__ieee128St12chars_format"))); #elif defined(USE_STRTOF128_FOR_FROM_CHARS) +// Overload for _Float128 is not defined inline in , define it here. from_chars_result from_chars(const char* first, const char* last, _Float128& value, chars_format fmt) noexcept