<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [coroutines] coroutines with potentially-throwing 'co_await promise.final_suspend()' expressions should be ill-formed"
   href="https://bugs.llvm.org/show_bug.cgi?id=46256">46256</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[coroutines] coroutines with potentially-throwing 'co_await promise.final_suspend()' expressions should be ill-formed
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++2a
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>lewissbaker@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The wording of [dcl.fct.def.coroutine]/15 states:
<span class="quote">> The expression co_­await promise.final_­suspend() shall not be potentially-throwing ([except.spec]).</span >


See <a href="http://eel.is/c++draft/dcl.fct.def.coroutine#15">http://eel.is/c++draft/dcl.fct.def.coroutine#15</a>
and <a href="http://eel.is/c++draft/except.spec#6">http://eel.is/c++draft/except.spec#6</a>

I believe this means that the compiler should reject with a diagnostic any
coroutine with a promise_type where `co_await promise.final_suspend()` is not
noexcept. ie. all of the following must be declared noexcept (if they form part
of the await-expression):
- promise_type::final_suspend()
- finalSuspendObj.operator co_await()
- finalSuspendAwaiter.await_ready()
- finalSuspendAwaiter.await_suspend()
- finalSuspendAwaiter.await_resume()
- finalSuspedObj destructor
- finalSuspendAwaiter destructor

Clang (and GCC) currently accepts code that that does not declare
final_suspend() as
noexcept.

e.g. see <a href="https://godbolt.org/z/Et_5eo">https://godbolt.org/z/Et_5eo</a></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>