public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r13-4263] libstdc++: Fix libstdc++ build on some targets [PR107811]
Date: Wed, 23 Nov 2022 10:54:49 +0000 (GMT)	[thread overview]
Message-ID: <20221123105449.095E13858291@sourceware.org> (raw)

https://gcc.gnu.org/g:e6a32c12b4ef87c084d29863c79503344126d101

commit r13-4263-ge6a32c12b4ef87c084d29863c79503344126d101
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Nov 23 11:53:54 2022 +0100

    libstdc++: Fix libstdc++ build on some targets [PR107811]
    
    fast_float library relies on size_t being 32-bit or larger and float/double
    being IEEE single/double.  Otherwise we only use strtod/strtof.
    In 3 spots I've used fast_float namespace stuff unconditionally in one
    function, which breaks the build if fast_float is disabled.
    
    2022-11-23  Jakub Jelinek  <jakub@redhat.com>
    
            PR libstdc++/107811
            * src/c++17/floating_from_chars.cc (__floating_from_chars_hex): Guard
            fast_float uses with #if USE_LIB_FAST_FLOAT and for mantissa_bits and
            exponent_bits provide a fallback.

Diff:
---
 libstdc++-v3/src/c++17/floating_from_chars.cc | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/src/c++17/floating_from_chars.cc b/libstdc++-v3/src/c++17/floating_from_chars.cc
index be1e1051b5c..3f5d4d411d9 100644
--- a/libstdc++-v3/src/c++17/floating_from_chars.cc
+++ b/libstdc++-v3/src/c++17/floating_from_chars.cc
@@ -783,11 +783,16 @@ namespace
     using uint_t = conditional_t<is_same_v<T, float>, uint32_t,
 				 conditional_t<is_same_v<T, double>, uint64_t,
 					       uint16_t>>;
+#if USE_LIB_FAST_FLOAT
     constexpr int mantissa_bits
       = fast_float::binary_format<T>::mantissa_explicit_bits();
     constexpr int exponent_bits
       = is_same_v<T, double> ? 11
 	: is_same_v<T, fast_float::floating_type_float16_t> ? 5 : 8;
+#else
+    constexpr int mantissa_bits = is_same_v<T, float> ? 23 : 52;
+    constexpr int exponent_bits = is_same_v<T, float> ? 8 : 11;
+#endif
     constexpr int exponent_bias = (1 << (exponent_bits - 1)) - 1;
 
     __glibcxx_requires_valid_range(first, last);
@@ -945,8 +950,11 @@ namespace
 	else if (mantissa_idx >= -4)
 	  {
 	    if constexpr (is_same_v<T, float>
+#if USE_LIB_FAST_FLOAT
 			  || is_same_v<T,
-				       fast_float::floating_type_bfloat16_t>)
+				       fast_float::floating_type_bfloat16_t>
+#endif
+			 )
 	      {
 		__glibcxx_assert(mantissa_idx == -1);
 		mantissa |= hexit >> 1;
@@ -1130,6 +1138,7 @@ namespace
       }
     if constexpr (is_same_v<T, float> || is_same_v<T, double>)
       memcpy(&value, &result, sizeof(result));
+#if USE_LIB_FAST_FLOAT
     else if constexpr (is_same_v<T, fast_float::floating_type_bfloat16_t>)
       {
 	uint32_t res = uint32_t{result} << 16;
@@ -1156,6 +1165,7 @@ namespace
 		 | ((uint32_t{result} & 0x8000) << 16));
 	memcpy(value.x, &res, sizeof(res));
       }
+#endif
 
     return {first, errc{}};
   }

                 reply	other threads:[~2022-11-23 10:54 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=20221123105449.095E13858291@sourceware.org \
    --to=jakub@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).