public inbox for
 help / color / mirror / Atom feed
* [committed] libstdc++: Revert pre-C++23 support for 16-bit float types [PR111060]
@ 2023-08-18 22:49 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2023-08-18 22:49 UTC (permalink / raw)
  To: libstdc++, gcc-patches

Tested x86_64-linux (--with-arch-32=i686). Pushed to trunk.

-- >8 --

In r14-3304-g1a566fddea212a and r14-3305-g6cf214b4fc97f5 I tried to
enable std::format for 16-bit float types before C++23. This causes
errors for targets where the types are defined but can't actually be
used, e.g. i686 without sse2.

Make the std::numeric_limits and std::formatter specializations for
_Float16 and __bfloat16_t depend on the __STDCPP_FLOAT16_T__ and
__STDCPP_BFLOAT16_T__ macros again, so they're only defined for C++23
when the type is fully supported. This is OK because the main point of
my earlier commits was to add better support for _Float32 and _Float64.
It seems fine for the new 16-bit types to only be supported for C++23,
as they were never present before GCC 13 anyway.


	PR target/111060
	* include/std/format (formatter): Only define specializations
	for 16-bit floating-point types for C++23.
	* include/std/limits (numeric_limits): Likewise.
 libstdc++-v3/include/std/format | 4 ++--
 libstdc++-v3/include/std/limits | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format
index 648f847ad96..f3d9ae152f9 100644
--- a/libstdc++-v3/include/std/format
+++ b/libstdc++-v3/include/std/format
@@ -2083,7 +2083,7 @@ namespace __format
-#if defined(__FLT16_DIG__)
+#ifdef __STDCPP_FLOAT16_T__
   // Reuse __formatter_fp<C>::format<float, Out> for _Float16.
   template<__format::__char _CharT>
     struct formatter<_Float16, _CharT>
@@ -2171,7 +2171,7 @@ namespace __format
-#if defined(__BFLT16_DIG__)
+#ifdef __STDCPP_BFLOAT16_T__
   // Reuse __formatter_fp<C>::format<float, Out> for bfloat16_t.
   template<__format::__char _CharT>
     struct formatter<__gnu_cxx::__bfloat16_t, _CharT>
diff --git a/libstdc++-v3/include/std/limits b/libstdc++-v3/include/std/limits
index 7a59e7520eb..ec0b7a1ca7b 100644
--- a/libstdc++-v3/include/std/limits
+++ b/libstdc++-v3/include/std/limits
 	= round_to_nearest; 						\
     }; 									\
-#ifdef __FLT16_DIG__
+#ifdef __STDCPP_FLOAT16_T__
 #ifdef __FLT32_DIG__
@@ -2002,7 +2002,7 @@ __glibcxx_float_n(128)
 # undef __max_digits10
-#ifdef __BFLT16_DIG__
+#ifdef __STDCPP_BFLOAT16_T__
     struct numeric_limits<__gnu_cxx::__bfloat16_t>
@@ -2079,7 +2079,7 @@ __glibcxx_float_n(128)
       static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
 	= round_to_nearest;
+#endif // __STDCPP_BFLOAT16_T__
 #if defined(_GLIBCXX_USE_FLOAT128)
 // We either need Q literal suffixes, or IEEE double.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-08-18 22:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-18 22:49 [committed] libstdc++: Revert pre-C++23 support for 16-bit float types [PR111060] Jonathan Wakely

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).