From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9936D3858C60; Wed, 1 Nov 2023 13:26:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9936D3858C60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1698845163; bh=wxwCmqrAWuKsMiR3jp+ynAqE5vH2B7MlrrPWMx/0Mnk=; h=From:To:Subject:Date:From; b=ruFS7GNrzzbUts5HtP48XFAId7GcusLelcQPnje++xmqePVwSez+0ZHW0etLlUlvq FwGztc9McAlwI20DJNGQ1vFvYQho0XP8KVozc16y4GIsK3Fz2ALkYk2S7qTLSW0IPK 0LFM71jQrgui5e7F2M6gOzK4wDSa+3nf6pbVL9aE= From: "federico at kircheis dot it" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/112335] New: missed optimization on reset and assign unique_ptr Date: Wed, 01 Nov 2023 13:26:03 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: federico at kircheis dot it 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D112335 Bug ID: 112335 Summary: missed optimization on reset and assign unique_ptr Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: federico at kircheis dot it Target Milestone: --- Given following snippet ---- #include struct s{ s(); ~s() noexcept; }; void bar1(std::unique_ptr& ps1, std::unique_ptr& ps2){ ps1.reset(); ps1 =3D std::move(ps2); } void bar2(std::unique_ptr& ps1, std::unique_ptr& ps2){ ps1 =3D std::move(ps2); } ---- If I am not mistaken, bar1 and bar2 should have exactly the same behavior, = but on https://godbolt.org/z/q4nKsPq7z it is possible to see that the generated code differs.=