[PATCH v2] libsupc++: Change _Unordered comparison value to minimum value of signed char.
Jonathan Wakely
jwakely@redhat.com
Wed Aug 27 10:48:47 GMT 2025
On Wed, 27 Aug 2025 at 11:05, Tomasz Kamiński <tkaminsk@redhat.com> wrote:
>
> 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.
> ---
> Changes in v3:
> * rename and simplify defintion of _Ncmp::unordered
Ah yes, we don't need to use an _Ugly name name for unordered.
> * simplify defintion of _M_reverse
>
> Testing on x86_64-linux and powerpc64le-linux. OK for trunk when test
> passes?
OK for trunk with the pretty printer change included.
More information about the Libstdc++
mailing list