]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Always treat __float128 as a floating-point type
authorJonathan Wakely <jwakely@redhat.com>
Wed, 2 Jul 2025 20:16:30 +0000 (21:16 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Fri, 11 Jul 2025 07:34:17 +0000 (08:34 +0100)
Similar to the previous commit that made is_integral_v<__int128>
unconditionally true, this makes is_floating_point_v<__float128>
unconditionally true. With the new extended floating-point types in
C++23 (std::float64_t etc.) it seems unhelpful for is_floating_point_v
to be true for them, but not for __float128. Especially as it is true on
some targets, because __float128 is just a typedef for long double.

This change makes is_floating_point_v<__float128> true whenever the type
is defined, giving less surprising and more portable behaviour.

libstdc++-v3/ChangeLog:

* include/bits/cpp_type_traits.h (__is_floating<__float128>):
Do not depend on __STRICT_ANSI__.
* include/bits/stl_algobase.h (__size_to_integer(__float128)):
Likewise.
* include/std/type_traits (__is_floating_point_helper<__float128>):
Likewise.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
libstdc++-v3/include/bits/cpp_type_traits.h
libstdc++-v3/include/bits/stl_algobase.h
libstdc++-v3/include/std/type_traits

index 770ad94b3b4de6c1dd2fe1a4b2970f03f00ec3ec..38cea4c67b76491306bd15f290743dc6991dda3a 100644 (file)
@@ -313,6 +313,15 @@ __INT_N(__int128)
       typedef __true_type __type;
     };
 
+#ifdef _GLIBCXX_USE_FLOAT128
+  template<>
+    struct __is_floating<__float128>
+    {
+      enum { __value = 1 };
+      typedef __true_type __type;
+    };
+#endif
+
 #ifdef __STDCPP_FLOAT16_T__
   template<>
     struct __is_floating<_Float16>
index 71ef2335a311f0f67363136d930a4cc1327e8f60..b104ec2536a0c960ba5739bcdfffa411b7e860f4 100644 (file)
@@ -1065,7 +1065,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
   __size_to_integer(double __n) { return (long long)__n; }
   inline _GLIBCXX_CONSTEXPR long long
   __size_to_integer(long double __n) { return (long long)__n; }
-#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128)
+#ifdef _GLIBCXX_USE_FLOAT128
   __extension__ inline _GLIBCXX_CONSTEXPR long long
   __size_to_integer(__float128 __n) { return (long long)__n; }
 #endif
index e88d04e44d76fefd391e3807749c6a069ec18387..78a5ee8c0eb4c820549ae70833fd00074c4ab556 100644 (file)
@@ -532,7 +532,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     : public true_type { };
 #endif
 
-#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128)
+#ifdef _GLIBCXX_USE_FLOAT128
   template<>
     struct __is_floating_point_helper<__float128>
     : public true_type { };