On Fri, 16 May 2025 at 12:04, Tomasz Kamiński wrote: > > For powerpc64 and sparc architectures that both have __float128 and 128bit > long double, > the __float128 is same type as long double/__iee128 and already formattable.
__ieee128 > > Remaining specializaiton make __float128 formattable on x86_64 via _Float128, "The remaining specialization makes ..." > however __float128 is now not formattable on x86_32 (-m32) with > -mlong-double-128, I don't think we need to care about that. > where __float128 is distinct type from long double that is 128bit IEEE. > > PR libstdc++/119246 > > libstdc++-v3/ChangeLog: > > * include/std/format (formatter<__float128, _Char_T): Define if > _GLIBCXX_FORMAT_F128 == 2. > --- > This patch avoids dealing with cases when long double is 128bit and thus > __float128 may be same as long double (it is same for powerpc and will be for > sparc), > but distinct for x86_32/-mlong-double-128. > > This preserve support formatting __float128 on x84_64, where it is formatted > using _Float128. > > Tested on x86_64, powerpc64. For format test checked both > -mabi=ibmlongdouble,-mabi=ieeelongdouble. > Rainer Orth confirmed that this also work with his patch adding __float128 > for sparc. > > OK for trunk? OK with the typos above fixed, and "IEE" in the first line of the commit fixed to "IEEE". > > 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 b1823db83bc..d1ca05105f9 100644 > --- a/libstdc++-v3/include/std/format > +++ b/libstdc++-v3/include/std/format > @@ -2973,11 +2973,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> > { > @@ -2995,9 +2993,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 > > -- > 2.49.0 >