title: Simple coroutine leaking with GCC 10
body: <p>Consider the following simple coroutine, which tracks its construction and destruction:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;coroutine&gt;
  #include &lt;iostream&gt;
  
  struct simple {
    static inline int x = 0;
    int id = 0;
    simple() : id{ x++ } { std::cout &lt;&lt; id &lt;&lt; " constructed\n"; }
    simple(simple&amp;&amp;) : id{ x++ } { std::cout &lt;&lt; id &lt;&lt; " move constructed\n"; }
    ~simple() { std::cout &lt;&lt; id &lt;&lt; " destructed\n"; }
  
    struct promise_type {
      simple get_return_object() { return {}; }
      void return_void() {}
      void unhandled_exception() { std::terminate(); }
      auto initial_suspend() noexcept { return std::suspend_never{}; }
      auto final_suspend() noexcept { return std::suspend_never{}; }
    };
  };
  
  simple f() { co_return; }
  
  int main() {
    f();
  }
  </code></pre>
  
  <p>When compiling with GCC 10.1, the output is:</p>
  
  <pre><code>0 constructed
  1 move constructed
  1 destructed
  </code></pre>
  
  <p>—notably, id <code>0</code> is never destructed. This is true even with GCC trunk.</p>
  
  <p>Is there something I've done wrong here, some hidden UB or the like? Or is GCC at fault here?</p>
  
  <p>As a comparison, I tried using Clang's experimental coroutine support, and got</p>
  
  <pre><code>0 constructed
  0 destructed
  </code></pre>
  
  <p>which is closer to what I was expecting. I also get this "correct" output even in GCC if I comment out the move constructor in the coroutine object. </p>
  
  <p>Live example: <a href="https://godbolt.org/z/UQVURi" rel="noreferrer">https://godbolt.org/z/UQVURi</a></p>