From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 9E9E13858D35 for ; Thu, 29 Jun 2023 12:50:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9E9E13858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688043005; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=8Ym9EvKQhJTYq2s3pu9GwOhkZcolL7i8u5ywlwwdjzo=; b=eQXPVAlqOenrIEEyVL5tPedDFe4ZOpsmq+yZs5gLKUAeUs1ytjIdyLcTtoj+n1qyRLr8E1 KTuw83XlkNpPjT4GLnPo2e50ZzLRhyTK8P5kN9KU50q8sFNHO8JijY2S10lxYLfKB3mboV ldSMNtf3SNpQq7q+2aW9FsaidpUEwCQ= Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-222-qvSVlqDDOnu-hWTXHg2wnw-1; Thu, 29 Jun 2023 08:50:03 -0400 X-MC-Unique: qvSVlqDDOnu-hWTXHg2wnw-1 Received: by mail-lj1-f198.google.com with SMTP id 38308e7fff4ca-2b69ed71d25so5921561fa.0 for ; Thu, 29 Jun 2023 05:50:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688043002; x=1690635002; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8Ym9EvKQhJTYq2s3pu9GwOhkZcolL7i8u5ywlwwdjzo=; b=ap6yolyrxkEqpCzX84+YRfdnWeQO1qlAEe4ent6m0xwHNUllCZI4toaKpCURhWZtOJ K046o5lBwS9ZqngupQIE9WN49/r1e9UgtnmSdqCZoHkMMgA97XxZX4qXOvvBBeyQmfR+ dwXpPReS5cDx7F2gtb0lHawXSRwDPqJ5kaT40Y8BByYdnnGOjNSRV71Hw2bYmFHDuoRF hfi/lF6s2/kPhwh3QBfNBXPO9aFK+Yr1wej4qOYi6mlQ6WRKQ2je+rxFAlgKluVw48S8 UVYPVb1WFHvp9hDRirk0HMLWmnZzXe3vVYlv+wii6w2u1AaWOSJyD3bCK1dFB8FgY8sZ qoRw== X-Gm-Message-State: AC+VfDw+iqnG1RuxyoNE9TBPmFDZXlfglN4F3j6yi9QxNPeOVTxaqhaC PQQlNp+12Q8/wqLnzn7cE8fhnGDFWJEHdfFu5HDMyK6m3ZQGVySCZLxvsslpbzb7RdZ+HpdwC5v m/lF5MPMZ3DOcWSYPkfKch3bCvVCtyyE= X-Received: by 2002:a2e:7d02:0:b0:2b6:a65f:729d with SMTP id y2-20020a2e7d02000000b002b6a65f729dmr7427030ljc.13.1688043002338; Thu, 29 Jun 2023 05:50:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5NX/s0fsZfM9wnVd+mnJRNcSRs1xFgGnNNbcpRULR6RXTkdyU9Uv+zSrPk6l5OQjCWuDOTbFiXLkOe2Z/WaZ4= X-Received: by 2002:a2e:7d02:0:b0:2b6:a65f:729d with SMTP id y2-20020a2e7d02000000b002b6a65f729dmr7427005ljc.13.1688043001768; Thu, 29 Jun 2023 05:50:01 -0700 (PDT) MIME-Version: 1.0 References: <20230531122222.4116868-1-jwakely@redhat.com> In-Reply-To: From: Jonathan Wakely Date: Thu, 29 Jun 2023 13:49:50 +0100 Message-ID: Subject: Re: [committed] libstdc++: Fix preprocessor conditions for std::from_chars [PR109921] To: Jonathan Wakely Cc: Christophe Lyon , libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/alternative; boundary="0000000000007c828c05ff442342" X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --0000000000007c828c05ff442342 Content-Type: text/plain; charset="UTF-8" On Thu, 1 Jun 2023 at 12:05, Jonathan Wakely wrote: > On Thu, 1 Jun 2023 at 10:30, Christophe Lyon via Libstdc++ > wrote: > > > > Hi, > > > > > > On Wed, 31 May 2023 at 14:25, Jonathan Wakely via Gcc-patches < > > gcc-patches@gcc.gnu.org> wrote: > > > > > Tested powerpc64le-linux. Pushed to trunk. > > > > > > -- >8 -- > > > > > > 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 _Flaot128 overload in terms of a > > > non-existing from_chars_strtod function. > > > > > > Only try to use __strtof128 if uselocale is available, otherwise > > > fallback to the long double overload of std::from_chars (which might > > > fallback to the double overload, which should use fast_float). > > > > > > This ensures we always define the full set of overloads, even if they > > > are not always accurate for all values of the wider types. > > > > > > 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. > > > (from_chars(const char*, const char*, _Float128&, > chars_format)) > > > Only use from_chars_strtod when USE_STRTOD_FOR_FROM_CHARS is > > > defined, otherwise parse a long double and convert to > _Float128. > > > > > > > > > This is causing a regression on aarch64: > > FAIL: libstdc++-abi/abi_check > > This is now PR 110077. > Hi Christophe, Is this fixed for aarch64 now? I think it should be. > > > > > > The log says: > > > > 3 added symbols > > 0 > > _ZNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEE11_S_allocateERS3_m > > std::__cxx11::basic_string, > > std::allocator >::_S_allocate(std::allocator&, unsigned > > long) > > version status: compatible > > GLIBCXX_3.4.32 > > type: function > > status: added > > > > 1 > > _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_S_allocateERS3_m > > std::__cxx11::basic_string, > > std::allocator >::_S_allocate(std::allocator&, unsigned long) > > version status: compatible > > GLIBCXX_3.4.32 > > type: function > > status: added > > > > 2 > > _ZSt10from_charsPKcS0_RDF128_St12chars_format > > std::from_chars(char const*, char const*, _Float128&, std::chars_format) > > version status: incompatible > > GLIBCXX_3.4.31 > > type: function > > status: added > > > > > > 2 undesignated symbols > > 0 > > _ZSt11__once_call > > std::__once_call > > version status: compatible > > GLIBCXX_3.4.11 > > type: tls > > type size: 8 > > status: undesignated > > > > 1 > > _ZSt15__once_callable > > std::__once_callable > > version status: compatible > > GLIBCXX_3.4.11 > > type: tls > > type size: 8 > > status: undesignated > > > > > > 1 incompatible symbols > > 0 > > _ZSt10from_charsPKcS0_RDF128_St12chars_format > > std::from_chars(char const*, char const*, _Float128&, std::chars_format) > > version status: incompatible > > GLIBCXX_3.4.31 > > type: function > > status: added > > > > > > > > ==== libstdc++-v3 check-abi Summary ==== > > > > # of added symbols: 3 > > # of missing symbols: 0 > > # of undesignated symbols: 2 > > # of incompatible symbols: 1 > > > > > > Can you have a look? > > > > Thanks, > > Christophe > > > > --- > > > libstdc++-v3/src/c++17/floating_from_chars.cc | 20 ++++++++++++------- > > > 1 file changed, 13 insertions(+), 7 deletions(-) > > > > > > diff --git a/libstdc++-v3/src/c++17/floating_from_chars.cc > > > b/libstdc++-v3/src/c++17/floating_from_chars.cc > > > index ebd428d5be3..eea878072b0 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 > > > @@ -1261,7 +1257,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). > > > @@ -1329,13 +1325,23 @@ > > > _ZSt10from_charsPKcS0_RDF128_St12chars_format(const char* first, > > > __ieee128& value, > > > chars_format fmt) > noexcept > > > __attribute__((alias > > > ("_ZSt10from_charsPKcS0_Ru9__ieee128St12chars_format"))); > > > -#elif defined(USE_STRTOF128_FOR_FROM_CHARS) > > > +#else > > > from_chars_result > > > from_chars(const char* first, const char* last, _Float128& value, > > > chars_format fmt) noexcept > > > { > > > +#ifdef USE_STRTOF128_FOR_FROM_CHARS > > > // fast_float doesn't support IEEE binary128 format, but we can use > > > strtold. > > > return from_chars_strtod(first, last, value, fmt); > > > +#else > > > + // Read a long double. This might give an incorrect result (e.g. > values > > > + // out of range of long double give an error, even if they fit in > > > _Float128). > > > + long double ldbl_val; > > > + auto res = std::from_chars(first, last, ldbl_val, fmt); > > > + if (res.ec == errc{}) > > > + value = ldbl_val; > > > + return res; > > > +#endif > > > } > > > #endif > > > > > > -- > > > 2.40.1 > > > > > > > > --0000000000007c828c05ff442342--