From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id F18263857C43; Tue, 21 Jul 2020 16:17:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F18263857C43 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1595348263; bh=l/3pSyV8QVtU5A44Odfyy3xukeabNTTMOROGLi+R3VE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=uJHKR0FXSZNvNSS5pHohcyMejZVc8IU2B0P0cCsMMr68ntTpjDBE1pxpKGpCqTIxt 7BYZqEzrayNgFP2QS83dJjVWoXBiijvjRLyfMc7eqLdBSVtvsLETea29hXY2jytZZF 6XWyETRTHOPCj95c8761G1RBTyWlKR6tDfrVXv7A= From: "sshannin at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/96269] optional comparison with nullopt fails Date: Tue, 21 Jul 2020 16:17:43 +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: 10.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: sshannin at gmail dot com X-Bugzilla-Status: UNCONFIRMED 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: Tue, 21 Jul 2020 16:17:44 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96269 --- Comment #2 from sshannin at gmail dot com --- (In reply to Jonathan Wakely from comment #1) > Your operator=3D=3D should be const-qualified. I don't disagree. I can also fully remove the operator=3D=3D and it compile= s as well (why should the presence of the non-const operator=3D=3D cause the com= parison with nullopt in one direction to instantiate it). But yeah, I lost something in my reduction in there. I think the main point= is that one direction of the comparison instantiates the templated operator=3D= =3D and the other doesn't. Consider this version of X instead, which avoids the const issues: struct X { int y; template bool operator=3D=3D(const T&o) const { return y =3D=3D o.summary(); } }; We again end up instantiating X's operator=3D=3D (even though we wouldn't c= all it) in the FLIP case (and thus fail to compile), but in the non-flip case everything seems fine.=