title: Must coroutine return type be copy- or move-constructible if it is passed in co_await
body: <p>In the following code example, the lambda coroutine <code>g</code> performs <code>co_await f</code>, where <code>f</code> is coroutine return type with deleted copy- and move- constructors:</p>
  <pre><code>#include &lt;coroutine&gt;
  
  class task {
  public:
      class task_promise {
      public:
          task get_return_object() { return task{handle_type::from_promise(*this)}; }
          auto initial_suspend() { return std::suspend_always{}; }
          auto final_suspend() noexcept { return std::suspend_never{}; }
          void return_void() {}
          void unhandled_exception() {}
      };
      using handle_type = std::coroutine_handle&lt;task_promise&gt;;
      handle_type handle;
  
      auto await_ready() { return false; }
      auto await_suspend(handle_type) { return handle; }
      void await_resume() { handle.resume(); }
  
      using promise_type = task_promise;
      task(handle_type h) : handle(h) {}
      task(const task&amp;) = delete;
      task&amp; operator=(const task&amp;) = delete;
      task(task&amp;&amp;) = delete;
      task&amp; operator=(task&amp;&amp;) = delete;
  };
  
  int main() {
      task f = []() -&gt; task { co_return; }();
      task g = [&amp;f]() -&gt; task { co_await f; }();
      g.handle.resume();
  }
  </code></pre>
  <p>The code is accepted in MSVC, but not in GCC.</p>
  <p>GCC 11.2 complains on the missing move-constructor:</p>
  <pre><code>error: use of deleted function 'task::task(task&amp;&amp;)'
  </code></pre>
  <p>and GCC trunk - on the missing copy-constructor:</p>
  <pre><code>error: use of deleted function 'task::task(const task&amp;)'
  </code></pre>
  <p>Demo: <a href="https://gcc.godbolt.org/z/1c7fajqn8" rel="nofollow noreferrer">https://gcc.godbolt.org/z/1c7fajqn8</a></p>
  <p>Which compiler is right here?</p>
  <p>P.S. There is a related question <a href="https://stackoverflow.com/questions/62429881/why-must-the-return-type-of-a-coroutine-be-move-constructible">Why must the return type of a coroutine be move-constructible?</a> but</p>
  <ul>
  <li>the issue there was fixed in GCC 10.2, while the example from this question is still valid in GCC 11 and trunk;</li>
  <li>this question asks about <code>co_await</code> requirements, while the other does not mention <code>co_await</code> at all;</li>
  <li>the other question is about move-constructor only, while here the latest GCC demands copy-constructor.</li>
  </ul>