<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/70478>70478</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Compiler incorrectly invokes `~final_awaitable` during unwinding of coroutine
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          cmazakas
      </td>
    </tr>
</table>

<pre>
    https://godbolt.org/z/zEoE6d5PE

If a promise type's `unhandled_exception()` bubbles the exception up, clang incorrectly generates a call to the `~final_awaitable` during unwinding.

This doesn't affect gcc or msvc and will work on clang-16. clang-15 and clang-17 both seem affected.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMUjlv3TwQ_DVUs7BAre5ChT_bAr4uRXqDx0piTJECSb2X5yK_PZD8clYpeGE5w-HMihjN7IgGVv_H6udM7GnxYVCreBdvImbS69uwpLRFVj4yHBmOs9fS25T7MDMc34_x4l8aXX96YfyZ8ceP-f8JBGzBryYSpNtGDNsIrOG7W4TTlvQrfVW0JeMdw45hzxoOcpfSUoS0EPwsw74xfAJlhZvBOOVDIJXsDWZyFESiCAKUsBaSP5Gs4d8m44R9FVdhkpCWDnK9B-Nm2N3VOG3cnP-u9_NiImhP0TFsE4hpIpVgVgp8gDVeFAin4WqshasPb-Ddh6CHosl_7Orzzv3QgvRpgUi03tlI55keSt2XvchoKJq-q7DukGfLUGIreCG7CWWnai2x57rVhaRSqaLqu8wMyLEsOLZFU7ec51Xfdk3XYVdPU9lowSpOqzA2t_ayHulkJsadhpZXbZdZIcnGM2ZER1c4iwzxSD0MB-ZB7nNkFbcmpviLJZlkaXjy62YshT_8N-7i3yj-q9_gJ1A--D0ZR9ke7N-dZdKyy1z5leF4vH9fHrbgv5BKDMdTdWQ4nr_6HgAA__81xeci">