I have a code that looks like this:
auto func() -> asio::awaitable<void> {
try {
co_await async_operation();
} catch(boost::system::system_error const& e) {
co_return co_await another_async_operation();
}
}
This code worked perfectly with GCC 11, but with GCC 12 it won't compile:
file.cpp:3:19: error: await expressions are not permitted in handlers
3 | co_return co_await another_async_operation();
| ^~~~~~~~
Why is that and how can I fix it?
This is explicitly forbidden in [expr.await]/2:
The error message here is pretty clear: you can't await in an exception handler. That it compiled before is a bug, this was always the rule (P0912R5).