mirror of
https://gcc.gnu.org/git/gcc.git
synced 2026-02-22 20:01:22 -05:00
For any minimum value of a signed type, its negation (with wraparound) results in the same value, behaving like zero. Representing the unordered result with this minimum value, along with 0 for equal, 1 for greater, and -1 for less in partial_ordering, allows its value to be reversed using unary negation. The operator<=(partial_order, 0) now checks if the reversed value is positive. This works correctly because the unordered value remains unchanged and thus negative. libstdc++-v3/ChangeLog: * libsupc++/compare (_Ncmp::_Unordered): Rename and change the value to minimum value of signed char. (_Ncomp::unordered): Renamed from _Unordered, the name is reserved by partial_ordered::unordered. (partial_ordering::_M_reverse()): Define. (operator<=(partial_ordering, __cmp_cat::__unspec)) (operator>=(__cmp_cat::__unspec, partial_ordering)): Implemented in terms of negated _M_value. (operator>=(partial_ordering, __cmp_cat::__unspec)) (operator<=(__cmp_cat::__unspec, partial_ordering)): Directly compare _M_value, as unordered value is negative. (partial_ordering::unordered): Handle _Ncmp::unoredred rename. * python/libstdcxx/v6/printers.py: Add -128 as integer value for unordered, keeping 2 to preserve backward compatibility. Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>