Issue 53098
Summary Return type of a coroutine must not be move-constructible
Labels new issue
Assignees
Reporter Fedr
    Current trunk of Clang rejects this valid program:
```
#include <coroutine>
#include <cstdlib>
class invoker {
public:
    class invoker_promise {
    public:
        invoker get_return_object() { return invoker{}; }
        auto initial_suspend() { return std::suspend_never{}; }
        auto final_suspend() noexcept { return std::suspend_never{}; }
        void return_void() {}
        void unhandled_exception() { std::abort(); }
    };
    using promise_type = invoker_promise;
    invoker() {}
    invoker(const invoker&) = delete;
    invoker& operator=(const invoker&) = delete;
    invoker(invoker&&) = delete;
    invoker& operator=(invoker&&) = delete;
};

invoker f() {
    co_return;
}
```
with the error:
```
<source>:21:9: error: call to deleted constructor of 'invoker'
invoker f() {
        ^
<source>:17:5: note: 'invoker' has been explicitly marked deleted here
    invoker(invoker&&) = delete;
    ^
<source>:7:17: note: member 'get_return_object' declared here
        invoker get_return_object() { return invoker{}; }
                ^
<source>:22:5: note: function is a coroutine due to use of 'co_return' here
    co_return;
    ^
```

Related discussion: https://stackoverflow.com/q/62429881/7325599
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to