Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f86130a commit 2bdce53Copy full SHA for 2bdce53
test/lazy_task_tests.cpp
@@ -350,4 +350,22 @@ TEST_CASE("chained fmap pipe operations")
350
}();
351
}
352
353
+TEST_CASE("lazy_task resumption uses tail call to avoid stack overflow")
354
+{
355
+ bool completedSynchronously = []() -> cppcoro::task<>
356
+ {
357
+ auto completesSynchronously = []() -> cppcoro::lazy_task<> { co_return; };
358
+
359
+ // Await a large number of synchronously-completing lazy_task values
360
+ // in a row. If the lazy_task's final_suspend is not doing tail-calls
361
+ // to resume the awaiter then this will blow the stack.
362
+ for (int i = 0; i < 100000; ++i)
363
364
+ co_await completesSynchronously();
365
+ }
366
+ }().is_ready();
367
368
+ CHECK(completedSynchronously);
369
+}
370
371
TEST_SUITE_END();
0 commit comments