https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117620
Bug ID: 117620 Summary: Problem passing rvalue to co_yield (maybe?) Product: gcc Version: 14.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mwd at md5i dot com Target Milestone: --- Created attachment 59606 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=59606&action=edit Example code When I compile the attached test code with -std=c++20, I get the following error: foo.cpp: In function ‘void get_values_2(get_values_2(int, int)::_Z12get_values_2ii.Frame*)’: foo.cpp:218:1: error: use of deleted function ‘constexpr Generator<int>::Generator(const Generator<int>&)’ 218 | } | ^ foo.cpp:15:7: note: ‘constexpr Generator<int>::Generator(const Generator<int>&)’ is implicitly declared as deleted because ‘Generator<int>’ declares a move constructor or move assignment operator 15 | class Generator : std::ranges::view_interface<Generator<T>> | ^~~~~~~~~ foo.cpp:215:1: note: use ‘-fdiagnostics-all-candidates’ to display considered candidates 218 | } | ^ Setting aside the fact that there are non-demangled identifiers in the output, this is triggered by the co_yield on line 214 of the code, which reads: co_yield elements_of{get_values(low, high)}; If I rewrite the code (recompile with -DFIXED) as follows: auto x = elements_of{get_values(low, high)}; co_yield std::move(x); I do not get an error and everything runs correctly. I cannot understand why these should generate different results. I also cannot figure out how and where the call to the purported Generator<int> copy constructor occurs.