On Tue, 15 Nov 2022 at 14:42, Jakub Jelinek wrote: > > On Tue, Nov 15, 2022 at 02:31:19PM +0000, Jonathan Wakely via Gcc-patches > wrote: > > Tested x86_64-linux and x86_64-w64-mingw32. Pushed to trunk. > > > > -- >8 -- > > > > std::format gives linker errors on targets that define __float128 but > > do not support using it with std::to_chars. This improves the handling > > of 128-bit flaoting-point types so they are disabled if unsupportable. > > > > libstdc++-v3/ChangeLog: > > > > PR libstdc++/107693 > > * include/std/format (_GLIBCXX_FORMAT_F128): Define to 2 when > > basic_format_arg needs to use its _M_f128 member. > > (__extended_floating_point, __floating_point): Replace with ... > > (__formattable_floating_point): New concept. > > * testsuite/std/format/functions/format.cc: Check whether > > __float128 is supported. Also test _Float128. > > > --- a/libstdc++-v3/include/std/format > > +++ b/libstdc++-v3/include/std/format > > > +#elif __FLT128_DIG__ && defined(__GLIBC_PREREQ) // see floating_to_chars.cc > > I'd just use here > #elif __FLT128_DIG__ && defined(_GLIBCXX_HAVE_FLOAT128_MATH) > instead. > > The reason for defined(__GLIBC_PREREQ) in floating_{to,from}_chars.cc > is that I didn't want to make the ABI of linux libstdc++.so.6 dependent > on whether gcc was built against glibc 2.26+ or older glibc. > So, the symbols exist in libstdc++.so.6 even for older glibcs, but it will > actually only work properly (without losing precision; otherwise it will > just go through long double) if at runtime one uses glibc 2.26+.
Yes, and my intention was that std::format would also support __float128, with the same imprecise behaviour. But could just limit std::format support to when std::to_chars works properly. > But in the headers, defined(_GLIBCXX_HAVE_FLOAT128_MATH) is used everywhere > else (which is true only when compiling against glibc 2.26+).