public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/103963] New: Coroutine return type must not be copy- or move-constructible
@ 2022-01-10 14:44 fchelnokov at gmail dot com
2022-04-18 19:09 ` [Bug c++/103963] Coroutine return type needs " iains at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: fchelnokov at gmail dot com @ 2022-01-10 14:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103963
Bug ID: 103963
Summary: Coroutine return type must not be copy- or
move-constructible
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: fchelnokov at gmail dot com
Target Milestone: ---
This is a valid program:
```
#include <coroutine>
class task {
public:
class task_promise {
public:
task get_return_object() { return
task{handle_type::from_promise(*this)}; }
auto initial_suspend() { return std::suspend_always{}; }
auto final_suspend() noexcept { return std::suspend_never{}; }
void return_void() {}
void unhandled_exception() {}
};
using handle_type = std::coroutine_handle<task_promise>;
handle_type handle;
auto await_ready() { return false; }
auto await_suspend(handle_type) { return handle; }
void await_resume() { handle.resume(); }
using promise_type = task_promise;
task(handle_type h) : handle(h) {}
task(const task&) = delete;
task& operator=(const task&) = delete;
task(task&&) = delete;
task& operator=(task&&) = delete;
};
int main() {
task f = []() -> task { co_return; }();
task g = [&f]() -> task { co_await f; }();
g.handle.resume();
}
```
The code is accepted in MSVC, but not in GCC.
GCC 11.2 complains on the missing move-constructor:
error: use of deleted function 'task::task(task&&)'
and GCC trunk - on the missing copy-constructor:
error: use of deleted function 'task::task(const task&)'
Demo: https://gcc.godbolt.org/z/1c7fajqn8
Related discussion: https://stackoverflow.com/q/70641924/7325599
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/103963] Coroutine return type needs not be copy- or move-constructible
2022-01-10 14:44 [Bug c++/103963] New: Coroutine return type must not be copy- or move-constructible fchelnokov at gmail dot com
@ 2022-04-18 19:09 ` iains at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: iains at gcc dot gnu.org @ 2022-04-18 19:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103963
Iain Sandoe <iains at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2022-04-18
CC| |iains at gcc dot gnu.org
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-04-18 19:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-10 14:44 [Bug c++/103963] New: Coroutine return type must not be copy- or move-constructible fchelnokov at gmail dot com
2022-04-18 19:09 ` [Bug c++/103963] Coroutine return type needs " iains at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).