https://gcc.gnu.org/g:2a82d4c859bd0eca4fe31fc79d234abd05e6a9d8
commit r16-2056-g2a82d4c859bd0eca4fe31fc79d234abd05e6a9d8 Author: Tomasz Kamiński <tkami...@redhat.com> Date: Fri May 16 07:12:36 2025 +0200 libstdc++: Format __float128 as _Float128 only when long double is not 128 IEEE [PR120976] For powerpc64 and sparc architectures that both have __float128 and 128bit long double, the __float128 is same type as long double/__ieee128 and already formattable. The remaining specialization makes __float128 formattable on x86_64 via _Float128, however __float128 is now not formattable on x86_32 (-m32) with -mlong-double-128, where __float128 is distinct type from long double that is 128bit IEEE. PR libstdc++/120976 libstdc++-v3/ChangeLog: * include/std/format (formatter<__float128, _Char_T): Define if _GLIBCXX_FORMAT_F128 == 2. Reviewed-by: Jonathan Wakely <jwak...@redhat.com> Signed-off-by: Tomasz Kamiński <tkami...@redhat.com> Diff: --- libstdc++-v3/include/std/format | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format index 46bd5d5ee6a0..5749aa1995a9 100644 --- a/libstdc++-v3/include/std/format +++ b/libstdc++-v3/include/std/format @@ -2998,11 +2998,9 @@ namespace __format }; #endif -#if defined(__SIZEOF_FLOAT128__) && _GLIBCXX_FORMAT_F128 > 1 - // Reuse __formatter_fp<C>::format<__format::__flt128_t, Out> for __float128. - // This formatter is not declared if _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT is true, - // as __float128 when present is same type as __ieee128, which may be same as - // long double. +#if defined(__SIZEOF_FLOAT128__) && _GLIBCXX_FORMAT_F128 == 2 + // Use __formatter_fp<C>::format<__format::__flt128_t, Out> for __float128, + // when long double is not 128bit IEEE type. template<__format::__char _CharT> struct formatter<__float128, _CharT> { @@ -3020,9 +3018,6 @@ namespace __format private: __format::__formatter_fp<_CharT> _M_f; - - static_assert( !is_same_v<__float128, long double>, - "This specialization should not be used for long double" ); }; #endif