<optional>: Potential constraint recursion for operator<=>(const optional<T>&, const U&) #1674
Labels
fixed
Something works now, yay!
LWG issue needed
A wording defect that should be submitted to LWG as a new issue
spaceship
C++20 operator <=>
While implementing
<=>
support forstd::optional
we stumbled across what appears to be constraint recursion for theoperator<=>
signature specified in [optional.comp.with.t]/25 when the second argument is a specialization ofoptional
. Specifically, checkingthree_way_comparable_with
seems to recurse via checking the constraint that e.g.<
is viable foroperator<(const optional<T>&, const optional<U>&)
, which it certainly is if<=>
is provided by the first signature. We avoided the recursion by adding an additional constraint to the first signature requiring thatU
is not a specialization ofoptional
, which is checked before thethree_way_comparable_with
constraint.STL/stl/inc/optional
Lines 646 to 650 in 4c862ee
Looking at it now (with the workaround disabled) the recursion only manifests when compiling with Clang. Given how differently Clang and MSVC handle C++20 relational operator rewrites it's not clear to me if the constraint recursion is real or an artifact of said rewrites in Clang. We need to reduce this to something library-free and then determine whether the bug is in Clang or the C++ Standard and deal with it appropriately. (I will nonetheless tag this "LWG issue needed" for the time being.)
The text was updated successfully, but these errors were encountered: