[llvm-bugs] [Bug 49453] New: throw expression in noexcept coroutine erroneously triggers -Wexception

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Mar 5 08:40:18 PST 2021


https://bugs.llvm.org/show_bug.cgi?id=49453

            Bug ID: 49453
           Summary: throw expression in noexcept coroutine erroneously
                    triggers -Wexception
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: eniebler at boost.org
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

The entire body of a coroutine is implicitly wrapped in a try/catch, and
exceptions are (usually) marshaled as exception_ptrs into the promise to be
rethrown when the coroutine type is awaited in another coroutine.

So, what looks like an unhandled `throw` in a `noexcept` function is in fact
not in the case of coroutines.

For example: 
unifex::task<int> bar() noexcept {
  throw 42;
  co_return 42;
}


warning: 'bar' has a non-throwing exception specification but can still throw
[-Wexceptions]
    throw 42;
    ^
<source>:18:11: note: function declared non-throwing here
task<int> bar() noexcept {
          ^     ~~~~~~~~
1 warning generated.

See https://godbolt.org/z/Pj7qPW

I suggest that `-Wexception` be suppressed for all coroutines.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210305/03334e93/attachment.html>


More information about the llvm-bugs mailing list