From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B2B4B3840C1E; Tue, 9 Feb 2021 22:46:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B2B4B3840C1E From: "redbeard0531 at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/99047] New: ICE on simple task coroutine example Date: Tue, 09 Feb 2021 22:46:35 +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: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redbeard0531 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: Tue, 09 Feb 2021 22:46:35 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99047 Bug ID: 99047 Summary: ICE on simple task coroutine example Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: redbeard0531 at gmail dot com Target Milestone: --- https://godbolt.org/z/ecxEbb Code compiles on MSVC and clang, and at least = on clang produces the expected output. #include #include template struct [[nodiscard]] task { struct promise_type { std::suspend_always initial_suspend() { return {}; } auto final_suspend() noexcept { struct awaiter { std::false_type await_ready() noexcept { return {}; } std::coroutine_handle<> await_suspend(std::coroutine_handle= <>) noexcept { return next; } void await_resume() noexcept { } std::coroutine_handle<> next; }; return awaiter{next}; } void unhandled_exception() noexcept { std::terminate(); } auto get_return_object() { return task(this); } auto coro() { return std::coroutine_handle::from_promise(*this); } void return_value(T val) { result.emplace(std::move(val)); } std::coroutine_handle<> next; std::optional result; }; task(task&& source) : p(std::exchange(source.p, nullptr)) {} explicit task(promise_type* p) : p(p) {} ~task() { if (p) p->coro().destroy(); } bool await_ready() noexcept { return p->coro().done(); } std::coroutine_handle<> await_suspend(std::coroutine_handle<> next) noexcept { p->next =3D next; return p->coro(); } const T& await_resume() const& noexcept { return *p->result; } promise_type* p; }; task five() { co_return 5; } task six() { co_return (co_await five()) + 1; } int main() { auto task =3D six(); task.p->next =3D std::noop_coroutine(); task.p->coro().resume(); return *task.p->result; } : In function 'void _Z4fivev.actor(five()::_Z4fivev.frame*)': :92:11: internal compiler error: in fold_convert_loc, at fold-const.c:2430 92 | task five() { | ^~~~ 0x1ce6f09 internal_error(char const*, ...) ???:0 0x6b6f43 fancy_abort(char const*, int, char const*) ???:0 0xc92cd4 fold_convert_loc(unsigned int, tree_node*, tree_node*) ???:0 0xd126ae gimple_boolify(tree_node*) ???:0 0xd1b720 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*= ), int) ???:0 0xd1bb4a gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*= ), int) [snipping many more frames]=