public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/98480] New: [coroutines] ICE on co_await in for-loop end condition. @ 2020-12-30 16:18 dpsicilia at gmail dot com 2021-03-12 15:21 ` [Bug c++/98480] " iains at gcc dot gnu.org ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: dpsicilia at gmail dot com @ 2020-12-30 16:18 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98480 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=c++20 -fcoroutines Compiler output: ICE (see godbolt link; full stack trace below). -------------------------------------------------------- // Standalone reproducer (same as godbolt link above). #include <coroutine> 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 = 0; i < co_await future{}; ++i ); // ICE -------------^ co_return 0; } -------------------------------------------------------- reproducer.cpp: In function ‘void _Z6co_foov.actor(co_foo()::_Z6co_foov.frame*)’: reproducer.cpp:17:3: internal compiler error: in fold_convert_loc, at fold-const.c:2435 285 | for( int i = 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, ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/98480] [coroutines] ICE on co_await in for-loop end condition. 2020-12-30 16:18 [Bug c++/98480] New: [coroutines] ICE on co_await in for-loop end condition dpsicilia at gmail dot com @ 2021-03-12 15:21 ` iains at gcc dot gnu.org 2021-03-15 15:51 ` cvs-commit at gcc dot gnu.org ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: iains at gcc dot gnu.org @ 2021-03-12 15:21 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98480 Iain Sandoe <iains at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |iains at gcc dot gnu.org Last reconfirmed| |2021-03-12 Status|UNCONFIRMED |ASSIGNED Ever confirmed|0 |1 --- Comment #1 from Iain Sandoe <iains at gcc dot gnu.org> --- Created attachment 50375 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50375&action=edit Patch under test I seem to have had a brainstorm when applying the changes needed for do {} while; and while () {} and omitted the ones for for. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/98480] [coroutines] ICE on co_await in for-loop end condition. 2020-12-30 16:18 [Bug c++/98480] New: [coroutines] ICE on co_await in for-loop end condition dpsicilia at gmail dot com 2021-03-12 15:21 ` [Bug c++/98480] " iains at gcc dot gnu.org @ 2021-03-15 15:51 ` cvs-commit at gcc dot gnu.org 2021-03-22 22:04 ` cvs-commit at gcc dot gnu.org 2021-03-24 12:40 ` iains at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2021-03-15 15:51 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98480 --- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Iain D Sandoe <iains@gcc.gnu.org>: https://gcc.gnu.org/g:26e0eb1071e318728bcd33f28d055729ac48792c commit r11-7675-g26e0eb1071e318728bcd33f28d055729ac48792c Author: Iain Sandoe <iain@sandoe.co.uk> Date: Thu Mar 11 14:22:37 2021 +0000 coroutines : Handle for await expressions in for stmts [PR98480]. The handling of await expressions in the init, condition and iteration expressions of for loops had been omitted. Fixed thus. gcc/cp/ChangeLog: PR c++/98480 * coroutines.cc (replace_continue): Rewrite continue into 'goto label'. (await_statement_walker): Handle await expressions in the initializer, condition and iteration expressions of for loops. gcc/testsuite/ChangeLog: PR c++/98480 * g++.dg/coroutines/pr98480.C: New test. * g++.dg/coroutines/torture/co-await-24-for-init.C: New test. * g++.dg/coroutines/torture/co-await-25-for-condition.C: New test. * g++.dg/coroutines/torture/co-await-26-for-iteration-expr.C: New test. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/98480] [coroutines] ICE on co_await in for-loop end condition. 2020-12-30 16:18 [Bug c++/98480] New: [coroutines] ICE on co_await in for-loop end condition dpsicilia at gmail dot com 2021-03-12 15:21 ` [Bug c++/98480] " iains at gcc dot gnu.org 2021-03-15 15:51 ` cvs-commit at gcc dot gnu.org @ 2021-03-22 22:04 ` cvs-commit at gcc dot gnu.org 2021-03-24 12:40 ` iains at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2021-03-22 22:04 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98480 --- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-10 branch has been updated by Iain D Sandoe <iains@gcc.gnu.org>: https://gcc.gnu.org/g:c38db3729b9a895a8dcf3ef28924822b28ad5c01 commit r10-9516-gc38db3729b9a895a8dcf3ef28924822b28ad5c01 Author: Iain Sandoe <iain@sandoe.co.uk> Date: Thu Mar 11 14:22:37 2021 +0000 coroutines : Handle for await expressions in for stmts [PR98480]. The handling of await expressions in the init, condition and iteration expressions of for loops had been omitted. Fixed thus. gcc/cp/ChangeLog: PR c++/98480 * coroutines.cc (replace_continue): Rewrite continue into 'goto label'. (await_statement_walker): Handle await expressions in the initializer, condition and iteration expressions of for loops. gcc/testsuite/ChangeLog: PR c++/98480 * g++.dg/coroutines/pr98480.C: New test. * g++.dg/coroutines/torture/co-await-24-for-init.C: New test. * g++.dg/coroutines/torture/co-await-25-for-condition.C: New test. * g++.dg/coroutines/torture/co-await-26-for-iteration-expr.C: New test. (cherry picked from commit 26e0eb1071e318728bcd33f28d055729ac48792c) ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/98480] [coroutines] ICE on co_await in for-loop end condition. 2020-12-30 16:18 [Bug c++/98480] New: [coroutines] ICE on co_await in for-loop end condition dpsicilia at gmail dot com ` (2 preceding siblings ...) 2021-03-22 22:04 ` cvs-commit at gcc dot gnu.org @ 2021-03-24 12:40 ` iains at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: iains at gcc dot gnu.org @ 2021-03-24 12:40 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98480 Iain Sandoe <iains at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Status|ASSIGNED |RESOLVED --- Comment #4 from Iain Sandoe <iains at gcc dot gnu.org> --- fixed for master and 10.3. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-03-24 12:40 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-12-30 16:18 [Bug c++/98480] New: [coroutines] ICE on co_await in for-loop end condition dpsicilia at gmail dot com 2021-03-12 15:21 ` [Bug c++/98480] " iains at gcc dot gnu.org 2021-03-15 15:51 ` cvs-commit at gcc dot gnu.org 2021-03-22 22:04 ` cvs-commit at gcc dot gnu.org 2021-03-24 12:40 ` iains at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).