From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1BC42385742C; Thu, 28 Apr 2022 17:28:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1BC42385742C From: "avi at scylladb dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/105373] miscompile involving lambda coroutines and an object bitwise copied instead of via the copy constructor Date: Thu, 28 Apr 2022 17:28:19 +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: 11.3.1 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: avi at scylladb 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: attachments.created 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, 28 Apr 2022 17:28:20 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105373 --- Comment #11 from Avi Kivity --- Created attachment 52899 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D52899&action=3Dedit simple(r) reproducer I was able to reduce it to something simple (102 lines), but I was only abl= e to verify that wrong code is generated on the gimple level (where my understan= ding is very limited). Still, to my inexperienced eyes it looks like an object w= ith a copy constructor is being copied bitwise. Compile with (gcc 11.3.1) g++ -Wfatal-errors -w -std=3Dgnu++20 -march=3Dwestmere -fvisibility=3D= hidden -c -o table.o table.i -fdump-tree-gimple -g=20 and observe in table.i.006t.gimple: struct lw_shared_ptr D.2740 [value-expr: frame_ptr->D.2740_4_5]; and then frame_ptr->D.2741_4_5.__old4 =3D frame_ptr->D.2740_4_5; in other places, variables of the same type are copied using the copy constructor.=