https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98842

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jonathan Wakely
<r...@gcc.gnu.org>:

https://gcc.gnu.org/g:3a415b6a93765f29bffd0582a001bf03c4b93f3c

commit r10-9996-g3a415b6a93765f29bffd0582a001bf03c4b93f3c
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Mon Jun 7 13:02:15 2021 +0100

    libstdc++: Constrain three-way comparison for std::optional [PR 98842]

    The operator<=>(const optional<T>&, const U&) operator is supposed to be
    constrained with three_way_comparable_with<U, T> so that it can only be
    used when T and U are weakly-equality-comparable and also three-way
    comparable.

    Adding that constrain completely breaks std::optional comparisons,
    because it causes constraint recursion. To avoid that, an additional
    check that U is not a specialization of std::optional is needed. That
    appears to be a defect in the standard and should be reported to LWG.

    Signed-off-by: Jonathan Wakely <jwak...@redhat.com>

    libstdc++-v3/ChangeLog:

            PR libstdc++/98842
            * include/std/optional (operator<=>(const optional<T>& const U&)):
            Add missing constraint and add workaround for template
            recursion.
            * testsuite/20_util/optional/relops/three_way.cc: Check that
            type without equality comparison cannot be compared when wrapped
            in std::optional.

    (cherry picked from commit adec14811714e22a6c1f7f0199adc05370f0d8b0)
  • [Bug libstdc++/98842] optional'... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to