public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r14-2753] libstdc++; Do not use strtold for hppa-hpux [PR110653]
Date: Mon, 24 Jul 2023 20:04:20 +0000 (GMT)	[thread overview]
Message-ID: <20230724200420.87A513858C5F@sourceware.org> (raw)

https://gcc.gnu.org/g:31c3b67dfc6e67773d13260bc38b833663698b74

commit r14-2753-g31c3b67dfc6e67773d13260bc38b833663698b74
Author: Jonathan Wakely <jwakely@redhat.com>
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); }

                 reply	other threads:[~2023-07-24 20:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230724200420.87A513858C5F@sourceware.org \
    --to=redi@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).