[PATCH] D82029: [Coroutines] Ensure co_await promise.final_suspend() does not throw
Xun Li via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 18 14:47:02 PDT 2020
lxfind marked an inline comment as done.
lxfind added inline comments.
================
Comment at: clang/test/SemaCXX/coroutine-final-suspend-noexcept.cpp:14
+struct coroutine_handle {
+ static coroutine_handle from_address(void *); // expected-note {{must be declared with 'noexcept'}}
+};
----------------
lewissbaker wrote:
> I'm not sure that we should be _requiring_ the compiler to emit an error for this line.
>
> The language specification does not require implementations to declare the from_address() method as noexcept, even though Clang now requires standard library implementations to declare this method as noexcept - this is an additional implementation requirement that Clang is placing on standard library implementations for them to be compatible with Clang's coroutines implementation.
>
> I guess this is probably ok to raise as an error, though, as most users will just be using the compiler-provided implementation and both libc++/libstdc++ are (currently) compatible.
`from_address` is in fact called as part of `co_await __promise.final_suspend()`.
Specifically, when this `co_await` is translated into a call to `finalSuspendObjAwaiter.await_suspend(handle)`, the handle parameter is obtained by calling `from_address`.
Since the specification requires that `co_await __promise.final_suspend()` should not be potentially throwing, it must requires `from_address` to be declared as `noexcept`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D82029/new/
https://reviews.llvm.org/D82029
More information about the cfe-commits
mailing list