public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95017] New: [coroutines] Failure to generate code for co_yield expression if its the only statement in a loop
@ 2020-05-08 23:50 lewissbaker.opensource at gmail dot com
2020-05-08 23:51 ` [Bug c++/95017] " lewissbaker.opensource at gmail dot com
2020-05-09 10:43 ` iains at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: lewissbaker.opensource at gmail dot com @ 2020-05-08 23:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95017
Bug ID: 95017
Summary: [coroutines] Failure to generate code for co_yield
expression if its the only statement in a loop
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: lewissbaker.opensource at gmail dot com
Target Milestone: ---
See https://godbolt.org/z/v-Tkvi
Given a simple coroutine generator<T> type, if I compile the following
coroutine with GCC it fails to generate code for the 'co_yield' expression if
the co_yield is the only statement in the loop body.
However, if I add another statement after the co_yield then it correctly
generates code for the co_yield expression.
Works: -std=c++2a -fcoroutines -DWITH_EXTRA_STATEMENT
Fails: -std=c++2a -fcoroutines
---------------------
generator<double> test()
{
double i = 0;
while(i++ < 5) {
// If the second statement below is compiled-out then GCC fails to
generate
// code for the co_yield expression and the loop completes without
// ever suspending.
co_yield i * 2;
#ifdef WITH_EXTRA_STATEMENT
(void)i;
#endif
}
}
int main() {
for (auto i : test()) {
printf("%f\t", i);
}
}
---------------------
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-05-09 10:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-08 23:50 [Bug c++/95017] New: [coroutines] Failure to generate code for co_yield expression if its the only statement in a loop lewissbaker.opensource at gmail dot com
2020-05-08 23:51 ` [Bug c++/95017] " lewissbaker.opensource at gmail dot com
2020-05-09 10:43 ` 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).