From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7741B3858C60; Mon, 10 Jan 2022 14:44:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7741B3858C60 From: "fchelnokov at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/103963] New: Coroutine return type must not be copy- or move-constructible Date: Mon, 10 Jan 2022 14:44:10 +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: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: fchelnokov 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: 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 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: Mon, 10 Jan 2022 14:44:10 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103963 Bug ID: 103963 Summary: Coroutine return type must not be copy- or move-constructible Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: fchelnokov at gmail dot com Target Milestone: --- This is a valid program: ``` #include class task { public: class task_promise { public: task get_return_object() { return task{handle_type::from_promise(*this)}; } auto initial_suspend() { return std::suspend_always{}; } auto final_suspend() noexcept { return std::suspend_never{}; } void return_void() {} void unhandled_exception() {} }; using handle_type =3D std::coroutine_handle; handle_type handle; auto await_ready() { return false; } auto await_suspend(handle_type) { return handle; } void await_resume() { handle.resume(); } using promise_type =3D task_promise; task(handle_type h) : handle(h) {} task(const task&) =3D delete; task& operator=3D(const task&) =3D delete; task(task&&) =3D delete; task& operator=3D(task&&) =3D delete; }; int main() { task f =3D []() -> task { co_return; }(); task g =3D [&f]() -> task { co_await f; }(); g.handle.resume(); } ``` The code is accepted in MSVC, but not in GCC. GCC 11.2 complains on the missing move-constructor: error: use of deleted function 'task::task(task&&)' and GCC trunk - on the missing copy-constructor: error: use of deleted function 'task::task(const task&)' Demo: https://gcc.godbolt.org/z/1c7fajqn8 Related discussion: https://stackoverflow.com/q/70641924/7325599=