From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 43ED73850425; Wed, 30 Dec 2020 16:18:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 43ED73850425 From: "dpsicilia at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/98480] New: [coroutines] ICE on co_await in for-loop end condition. Date: Wed, 30 Dec 2020 16:18:32 +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: 10.2.0 X-Bugzilla-Keywords: 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: 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: Wed, 30 Dec 2020 16:18:32 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98480 Bug ID: 98480 Summary: [coroutines] ICE on co_await in for-loop end condition. Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: dpsicilia at gmail dot com Target Milestone: --- Quick Minimal reproducer: https://godbolt.org/z/Wrv54E -------------------------------------------------------- Summary: when a co_await is placed in the end condition of a for loop it causes gcc to ICE. If I pull the co_await out and store the result in a variable then the issue goes away. -------------------------------------------------------- Version of GCC: 10.2.0 System type: Linux x64 Command line: -std=3Dc++20 -fcoroutines Compiler output: ICE (see godbolt link; full stack trace below). -------------------------------------------------------- // Standalone reproducer (same as godbolt link above). #include struct future { struct promise_type { void return_value(int) {} auto initial_suspend() { return std::suspend_never{}; } auto final_suspend() { return std::suspend_never{}; } void unhandled_exception() {} future get_return_object() { return {}; } }; bool await_ready() { return true; } void await_suspend(std::coroutine_handle<>) {} int await_resume() { return 0; } }; future co_foo() { for( int i =3D 0; i < co_await future{}; ++i ); // ICE -------------^ co_return 0; } -------------------------------------------------------- reproducer.cpp: In function =E2=80=98void _Z6co_foov.actor(co_foo()::_Z6co_foov.frame*)=E2=80=99: reproducer.cpp:17:3: internal compiler error: in fold_convert_loc, at fold-const.c:2435 285 | for( int i =3D 0; i < co_await future{}; ++i ) | ^~~ 0x5fd0ae fold_convert_loc(unsigned int, tree_node*, tree_node*) ../../gcc/fold-const.c:2435 0x9fae2a gimplify_cond_expr ../../gcc/gimplify.c:4149 0x9f2f1b gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*= ), int) ../../gcc/gimplify.c:13513 0x9f3705 gimplify_stmt(tree_node**, gimple**) ../../gcc/gimplify.c:6825 0x9f3705 gimplify_statement_list ../../gcc/gimplify.c:1869 0x9f3705 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*= ), int) ../../gcc/gimplify.c:14000 0x9f64f9 gimplify_stmt(tree_node**, gimple**) ../../gcc/gimplify.c:6825 0x9f64f9 gimplify_and_add(tree_node*, gimple**) ../../gcc/gimplify.c:486 0x9f64f9 gimplify_loop_expr ../../gcc/gimplify.c:1843 0x9f37b6 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*= ), int) ../../gcc/gimplify.c:13761 0x9f3705 gimplify_stmt(tree_node**, gimple**) ../../gcc/gimplify.c:6825 0x9f3705 gimplify_statement_list ../../gcc/gimplify.c:1869 0x9f3705 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*= ), int) ../../gcc/gimplify.c:14000 0x9f3705 gimplify_stmt(tree_node**, gimple**) ../../gcc/gimplify.c:6825 0x9f3705 gimplify_statement_list ../../gcc/gimplify.c:1869 0x9f3705 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*= ), int) ../../gcc/gimplify.c:14000 0x9f9849 gimplify_stmt(tree_node**, gimple**) ../../gcc/gimplify.c:6825 0x9f9849 gimplify_bind_expr ../../gcc/gimplify.c:1424 0x9f3102 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*= ), int) ../../gcc/gimplify.c:13757 0x9f3705 gimplify_stmt(tree_node**, gimple**) ../../gcc/gimplify.c:6825 Please submit a full bug report,=