From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2367838930D1; Thu, 18 Jun 2020 15:50:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2367838930D1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1592495436; bh=lDUSQ8DgPszxHV08iAyDKq1YyV1dwlB9dVWkMYTnUUA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=FU319G8BIATe1M12GlLZjziLZrKq17bbaGH0ozEXLs6laO1gE5kVJv9lENrmpoOJk GduUem05zBnPZwHbfX8hWOKz9Tnz59sApm7AX31k8Cks5ntf/vlaBnRnwVD13liPPv P0nrslL+DrwLHtNk8ufJ6ub2DMI21rHAZPWDpt4o= From: "lewissbaker.opensource at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/95736] coroutine method improperly copies awaitable Date: Thu, 18 Jun 2020 15:50: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: 10.1.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: lewissbaker.opensource 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: Thu, 18 Jun 2020 15:50:36 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95736 Lewis Baker changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lewissbaker.opensource@gmai | |l.com --- Comment #1 from Lewis Baker -= -- I've also investigated this a bit more and have annotated the assembly of t= he code being generated by GCC in this example (slightly modified). https://godbolt.org/z/_HJNHC Immediately before the 'co_await foo' expression the compiler generates a copy of the this->foo member into the coroutine frame. But it does this doing the equivalent of a memcpy() rather than calling the copy-constructor. The compiler should not be making this copy of the operand to 'co_await' and should instead be passing the address of the 'this->foo' member to the as the implicit object parameter in the call to await_ready/await_suspend/await_resume.=