diff options
| author | Tomasz Kamiński <tkaminsk@redhat.com> | 2025-08-26 14:34:35 +0200 |
|---|---|---|
| committer | Tomasz Kamiński <tkaminsk@redhat.com> | 2025-08-27 14:50:20 +0200 |
| commit | fcb3009a32dc33906934a2360e556dfeb98980cf (patch) | |
| tree | 485f9dc16734bab521342ab856a5068b7c941754 /libstdc++-v3/python | |
| parent | f707c093dee0468a3ef837a6c40afcf4c7fa7e46 (diff) | |
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>
Diffstat (limited to 'libstdc++-v3/python')
| -rw-r--r-- | libstdc++-v3/python/libstdcxx/v6/printers.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index 5f5963cb595..e5336b7fa89 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -1749,7 +1749,11 @@ class StdCmpCatPrinter(printer_base): if self._typename == 'strong_ordering' and self._val == 0: name = 'equal' else: - names = {2: 'unordered', -1: 'less', 0: 'equivalent', 1: 'greater'} + names = { + -1: 'less', 0: 'equivalent', 1: 'greater', + # GCC 10-15 used 2 for unordered + -128: 'unordered', 2: 'unordered' + } name = names[int(self._val)] return 'std::{}::{}'.format(self._typename, name) |
