https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95346
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Iain D Sandoe <ia...@gcc.gnu.org>: https://gcc.gnu.org/g:4f2d05ef0142d269964e165c14c6f7fe4bdfd5a3 commit r11-952-g4f2d05ef0142d269964e165c14c6f7fe4bdfd5a3 Author: Iain Sandoe <i...@sandoe.co.uk> Date: Thu Jun 4 17:14:37 2020 +0100 coroutines: Fix missed ramp function return copy elision [PR95346]. Confusingly, "get_return_object ()" can do two things: - Firstly it can provide the return object for the ramp function (as the name suggests). - Secondly if the type of the ramp function is different from that of the get_return_object call, this is used as a single parameter to a CTOR for the ramp's return type. In the first case we can rely on finish_return_stmt () to do the necessary processing for copy elision. In the second case, we should have passed a prvalue to the CTOR as per the standard comment, but I had omitted the rvalue () call. Fixed thus. gcc/cp/ChangeLog: PR c++/95346 * coroutines.cc (morph_fn_to_coro): Ensure that the get- return-object is constructed correctly; When it is not the final return value, pass it to the CTOR of the return type as an rvalue, per the standard comment. gcc/testsuite/ChangeLog: PR c++/95346 * g++.dg/coroutines/pr95346.C: New test.