]> git.ipfire.org Git - thirdparty/gcc.git/commit
libsupc++: Change _Unordered comparison value to minimum value of signed char.
authorTomasz Kamiński <tkaminsk@redhat.com>
Tue, 26 Aug 2025 12:34:35 +0000 (14:34 +0200)
committerTomasz Kamiński <tkaminsk@redhat.com>
Wed, 27 Aug 2025 12:50:20 +0000 (14:50 +0200)
commitfcb3009a32dc33906934a2360e556dfeb98980cf
tree485f9dc16734bab521342ab856a5068b7c941754
parentf707c093dee0468a3ef837a6c40afcf4c7fa7e46
libsupc++: Change _Unordered comparison value to minimum value of signed char.

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>
libstdc++-v3/libsupc++/compare
libstdc++-v3/python/libstdcxx/v6/printers.py