public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95736] New: coroutine method improperly copies awaitable
@ 2020-06-18  8:07 mizvekov at gmail dot com
  2020-06-18 15:50 ` [Bug c++/95736] " lewissbaker.opensource at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: mizvekov at gmail dot com @ 2020-06-18  8:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95736

            Bug ID: 95736
           Summary: coroutine method improperly copies awaitable
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mizvekov at gmail dot com
  Target Milestone: ---

Created attachment 48752
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48752&action=edit
example reproduction

Compiling attached program with `g++ -std=c++20 -fcoroutines -O0 -ggdb3
test.cc` and then running gives unexpected result:

```
coro begin
suspending to footable 0x7fffee14dee0
operator() on 0x7ffff5c307e0
a.out: test.cc:33: void footable::operator()(): Assertion `handle' failed.
fish: “./a.out” terminated by signal SIGABRT (Abort)
```

Expected result, as obtained from clang with `clang++ -std=c++20 -stdlib=libc++
-O0 -ggdb3 test.cc`:
```
coro begin
suspending to footable 0x7ffff6441330
operator() on 0x7ffff6441330
resuming from footable 0x7ffff6441330
coro end
coro returns
final suspend
releasing
done
```

Notice how on the gcc (first) case, it fails because `await_suspend` and
`operator()` are operating on different copies of the awaiter, even though the
awaiter is not copy constructible.

I failed to reproduce this problem if the coroutine body was not a class
method.

Compiler explorer workspace for convenience: https://godbolt.org/z/_yqwCV

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-06-30 12:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-18  8:07 [Bug c++/95736] New: coroutine method improperly copies awaitable mizvekov at gmail dot com
2020-06-18 15:50 ` [Bug c++/95736] " lewissbaker.opensource at gmail dot com
2020-06-21 12:56 ` iains at gcc dot gnu.org
2020-06-27  9:40 ` cvs-commit at gcc dot gnu.org
2020-06-30 12:46 ` cvs-commit at gcc dot gnu.org
2020-06-30 12:49 ` 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).