The following code:
try {
throw 42;
} catch (int i) {
co_await somefuture;
}
compiles with clang 6 and 7 with -fcoroutines-ts. However, it does not compile with Visual C++ 15 (2017) Visual C++ 16 (2019) with /await with the error
C2304: 'co_await' cannot be used inside of a catch block
The C++20 standard draft and cppreference do not seem to mention anything about it.
Is it a missing feature in the Microsoft compiler or did I misunderstand the standard?
From [expr.await], emphasis mine:
An await-expression shall appear only in a potentially-evaluated expression within the compound-statement of a function-body outside of a handler ([except]).
MSVC is correct to reject.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With