Description
The standard says: "The expression promise.get_return_object() is used to initialize the returned reference or value result object of a call to a coroutine. The call to get_return_object is sequenced before the call to initial_suspend and is invoked at most once." [dcl.fct.def.coroutine]
However, if you look at the result of the following program https://godbolt.org/z/8e647znb6, it can be seen that the standard is not being followed.
Firstly, it is not the expression itself that is used for initialization, but its result
Secondly, if this result is a reference, it is still stored as a value
As a consequence, the behavior is not what the user expects. If we return an non-copyable and non-movable object type reference, we will get a compilation error. If the result contains references to the promise object, it may be destroyed before it is used. etc.
P.S. The same thing is observed in gcc
Edit1: When I wrote about returning the reference, i meant the return type of get_return_object(), and not the coroutine itself