On 03/03/22 22:38 +0000, Jonathan Wakely wrote:
Tested x86_64-linux (-m32/-m64), powerpc64-linux (-m32/-m64), powerpc64le-linux, powerpc-aix (maix32/-maix64/-mlong-double-128).Pushed to trunk. I'm inclined to backport this to gcc-11 after some soak time on trunk (but not gcc-10, because it needs __builtin_bit_cast). -- >8 -- This removes a FIXME in <compare>, defining the total order for floating-point types. I originally opened PR96526 to request a new compiler built-in to implement this, but now that we have std::bit_cast it can be done entirely in the library. The implementation is based on the glibc definitions of totalorder, totalorderf, totalorderl etc. I think this works for all the types that satisfy std::floating_point today, and should also work for the types expected to be added by P1467 except for std::bfloat16_t. It also supports some additional types that don't currently satisfy std::floating_point, such as __float80, but we probably do want that to satisfy the concept for non-strict modes. libstdc++-v3/ChangeLog: PR libstdc++/96526 * libsupc++/compare (strong_order): Add missing support for floating-point types. * testsuite/18_support/comparisons/algorithms/strong_order_floats.cc: New test.
That commit produces a warning due to a typedef that is only needed for some targets, which caused: FAIL: g++.dg/warn/Wstringop-overflow-6.C -std=gnu++20 (test for excess errors) Here's the fix. Tested x86_64-linux, pushed to trunk.
commit 289f65d643e18210433e0f08ccaaf5b08b3d6f39 Author: Jonathan Wakely <[email protected]> Date: Fri Mar 4 10:43:29 2022 libstdc++: Fix -Wunused-local-typedefs warning in <compare> libstdc++-v3/ChangeLog: * libsupc++/compare (strong_order::_S_fp_cmp): Move typedef inside #if condition. diff --git a/libstdc++-v3/libsupc++/compare b/libstdc++-v3/libsupc++/compare index a8747207b23..050cf7ed20d 100644 --- a/libstdc++-v3/libsupc++/compare +++ b/libstdc++-v3/libsupc++/compare @@ -850,8 +850,6 @@ namespace std return strong_ordering::equal; // All bits are equal, we're done. using enum _Fp_fmt; - using _Int = decltype(__ix); - constexpr auto __fmt = _S_fp_fmt<_Tp>(); if constexpr (__fmt == _Dbldbl) // double-double @@ -899,6 +897,8 @@ namespace std // bit to be reversed. Flip that to give desired ordering. if (__builtin_isnan(__x) && __builtin_isnan(__y)) { + using _Int = decltype(__ix); + constexpr int __nantype = __fmt == _Binary32 ? 22 : __fmt == _Binary64 ? 51 : __fmt == _Binary128 ? 111
