https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108643
Arsen Arsenović <arsen at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |arsen at gcc dot gnu.org --- Comment #1 from Arsen Arsenović <arsen at gcc dot gnu.org> --- both clang++ and g++ fail here, I believe it is the vector, string and generator that you pass to vector_to_generator, test and test respectively that expire before they get to be used in the coroutine body because. outlining the values you use works: int main() { std::vector vec {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; std::string prompt { "test:" }; for (auto &i : test(vector_to_generator(vec), prompt)) { } } ... as does not using reference types in the helper functions: coro::generator<const int> vector_to_generator(std::vector<int> test) { for (auto &i : test) { co_yield i; } } coro::generator<const int> test(coro::generator<const int> source, std::string prompt) { for (auto &i : source) { std::cout << prompt << i << std::endl; co_yield i; } } int main() { for (auto &i : test(vector_to_generator({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}), "test:")) { } } there's a case to be made here about a missing diagnostic, however