]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Fix std::to_chars for IEEE128 long double
authorJonathan Wakely <jwakely@redhat.com>
Thu, 10 Feb 2022 14:06:27 +0000 (14:06 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Mon, 14 Feb 2022 12:34:21 +0000 (12:34 +0000)
The preprocessor check for _GLIBCXX_USE_FLOAT128 is the wrong condition,
because when the compiler is built with --with-long-double-format=ieee
configure determines that __float128 is the same as long double, and so
should not be used. But we do want the std::to_chars overloads for
__float128 in that case, because the floating_to_chars.cc file is built
with -mabi=ibmlongdouble and so the __float128 overloads are actually
the 'long double' ones for -mabi=ieeelongdouble code.

This fixes missing definitions of the __float128 overloads of
std::to_chars for --with-long-double-format=ieee builds. Without this,
there are symbols present in the --with-long-double-abi=ibm build which
are missing from the --with-long-double-abi=ieee build.

libstdc++-v3/ChangeLog:

* src/c++17/floating_to_chars.cc (FLOAT128_TO_CHARS): Depend on
LONG_DOUBLE_ALT128_COMPAT instead of USE_FLOAT128.

libstdc++-v3/src/c++17/floating_to_chars.cc

index 8da2f2385a01c81de1334073e1d5ba61f9fc6a7d..5825e661bf42a96d9322343a2179ad72f81dd862 100644 (file)
@@ -76,16 +76,12 @@ extern "C" int __sprintfieee128(char*, const char*, ...);
 # define LONG_DOUBLE_KIND LDK_UNSUPPORTED
 #endif
 
-#if defined _GLIBCXX_USE_FLOAT128 && __FLT128_MANT_DIG__ == 113
+// For now we only support __float128 when it's the powerpc64 __ieee128 type.
+#if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && __FLT128_MANT_DIG__ == 113
 // Define overloads of std::to_chars for __float128.
 # define FLOAT128_TO_CHARS 1
 #endif
 
-// For now we only support __float128 when it's the powerpc64 __ieee128 type.
-#ifndef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT
-# undef FLOAT128_TO_CHARS
-#endif
-
 #ifdef FLOAT128_TO_CHARS
 using F128_type = __float128;
 #else