[PATCH] D116204: [C++20] [Coroutines] Allow promise_type to not define return_void or return_value

Chuanqi Xu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 23 18:03:58 PST 2021


ChuanqiXu added inline comments.


================
Comment at: clang/test/SemaCXX/coroutines.cpp:987
+//
+// So it isn't ill-formed if the promise doesn't define return_value and return_void. It is just a UB.
+coro<promise_no_return_func> no_return_value_or_return_void() {
----------------
Quuxplusone wrote:
> It's not UB; it's //potential// UB.
> My understanding is that such a coroutine could still be used:
> - if it exits by throwing an exception instead of `co_return`'ing
> - if it suspends and then its caller `destroy`s it instead of `resume`ing it
> 
> I believe it would be useful to have some actual tests for these scenarios, that would actually run and check that the runtime behavior is correct, or at least check the IR that was generated. Is that possible?
Yes, such a coroutine could still be used. AFAIK, we couldn't make tests which would run actually. All the test cases I know is about pattern match. So we couldn't make tests in clang to run actually for this. I have tested it locally. And I think it is unnecessary to check the IR was generated since this patch didn't add new statements except a null statement as marker.

BTW, it shows another big issue for coroutines. We lack test-suite and benchmarks now. Now I tested the correctness of the compiler by test it in our internal projects. But we need an open source test suites absolutely. This is true for benchmarks. I thought to make the two things... but I don't find time for it now...


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116204/new/

https://reviews.llvm.org/D116204



More information about the cfe-commits mailing list