From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 175F4384001D; Thu, 22 Jul 2021 15:34:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 175F4384001D From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/98842] optional's spaceship operations generates wrong code when operator== is not present Date: Thu, 22 Jul 2021 15:34:31 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Jul 2021 15:34:32 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98842 --- Comment #5 from CVS Commits --- The releases/gcc-10 branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:3a415b6a93765f29bffd0582a001bf03c4b93f3c commit r10-9996-g3a415b6a93765f29bffd0582a001bf03c4b93f3c Author: Jonathan Wakely Date: Mon Jun 7 13:02:15 2021 +0100 libstdc++: Constrain three-way comparison for std::optional [PR 98842] The operator<=3D>(const optional&, const U&) operator is supposed to= be constrained with three_way_comparable_with 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 libstdc++-v3/ChangeLog: PR libstdc++/98842 * include/std/optional (operator<=3D>(const optional& 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)=