From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6052E3858008; Tue, 19 Dec 2023 15:54:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6052E3858008 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1703001277; bh=2tNWIQg2giSZArA/Yp3QBHFywJ7f+lhuG/LUeSPss6E=; h=From:To:Subject:Date:In-Reply-To:References:From; b=dTsOYesdZftSzGKSYr/ryRuwQomazpEiK+z+1hTVceAUnAO7T0OMQwtJwiG2pbMm+ xbWzpq9gqlaLq4Lo1Re24WEc8cyz4vt8sw+LzOLjR26QFvudemBT0w8aPv0A4uWeGZ 4WzGSi93hKAoVSZ6I93prXSaDuOqNBVopoie4/eY= From: "mpolacek at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/113064] assignement from temporary sometimes invokes copy-assign instead of move-assign operator Date: Tue, 19 Dec 2023 15:54:36 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: mpolacek at gcc dot gnu.org 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113064 --- Comment #6 from Marek Polacek --- (In reply to m.cencora from comment #4) > This also might be a just another symptom of the same root cause: >=20 > struct bar > { > bar() =3D default; >=20 > bar(const bar&); > bar(bar&&); >=20 > bar& operator=3D(const bar&); > bar& operator=3D(bar&&); > }; >=20 > struct foo > { > operator const bar& () const &; >=20 > operator bar& () &; >=20 > operator bar&&() &&; > }; >=20 > void test() > { > bar a =3D foo{}; // ok >=20 > a =3D foo{}; // not ok - ambiguous call, but why? &&-qualified looks = like > a better match >=20 > foo f; > a =3D f; // ok >=20 > a =3D static_cast(foo{}); // ok > } Here the error showed up in r9-6486: commit c7e936dbc7f59ad09c28ef57e5399a4256061747 Author: Jason Merrill Date: Mon Mar 11 23:19:22 2019 -0400 PR c++/86521 - wrong overload resolution with ref-qualifiers. Here we were wrongly treating binding a const lvalue ref to an xvalue as direct binding, which is wrong under [dcl.init.ref] and [over.match.ref= ].=