From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8276D386103F; Sat, 9 Jan 2021 19:56:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8276D386103F From: "dpsicilia at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/98401] Temporaries passed to co_await sometimes cause an extraneous call to destructor at incorrect address Date: Sat, 09 Jan 2021 19:56:23 +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: 10.2.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: dpsicilia 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: cc 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: Sat, 09 Jan 2021 19:56:23 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98401 David Sicilia changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dpsicilia at gmail dot com --- Comment #2 from David Sicilia --- I believe I've just run into this as well. In some cases (which I don't kn= ow how to describe) when I co_await on a temporary I get an error that manifes= ts as a sanitizer error (in my build): "runtime error: member call on misaligned address 0x00000095c55e for type 'struct optional', which requires 8 byte alignment." When I store the awaitable first in a local variable, then co_await on that, the issue goes away. Unfortunately I have not managed to produce a minimal reproducer yet, so not sure how much this helps, but it would seem that gcc's handling of co_wait'= ing on temporaries needs to be looked at. Also want to point out that with Milo Brandt's reproducer, it has different output between gcc 10.2 and gcc trunk: gcc 10.2: https://godbolt.org/z/rPdY9f gcc trunk: https://godbolt.org/z/Y1adoq The gcc 10.2 output looks correct to me, so it could be a regression? That said, I observed my issue on gcc 10.2 (not trunk), so it may not be a regression.=