public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95519] New: [coroutines] non-functions for promise_type::return_void not supported
@ 2020-06-03 22:34 bruck.michael at gmail dot com
  2020-06-04 20:11 ` [Bug c++/95519] " iains at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: bruck.michael at gmail dot com @ 2020-06-03 22:34 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95519
           Summary: [coroutines] non-functions for
                    promise_type::return_void not supported
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bruck.michael at gmail dot com
  Target Milestone: ---

The standard only requires certain expressions e.g. "p.return_void()", not
specifically functions. return_void is the only one I tested, presumably this
applies to more.

The example uses a struct with operator() and a function pointer.
Both work on clang.

https://gcc.godbolt.org/z/oW8eQ3


#ifndef __clang__
#include <coroutine>
#else
#include <experimental/coroutine>
namespace std { using namespace experimental; }
#endif

#include <cstdio>

struct rv
{
    void operator ()(){
        printf("call to operator\n");
    }
};

struct pt
{
    using handle_t = std::coroutine_handle<pt>;
    auto get_return_object() noexcept { return handle_t::from_promise(*this); }

    std::suspend_never initial_suspend() const noexcept { return {}; }
    std::suspend_never final_suspend() const noexcept { return {}; }
    //void return_void() const noexcept { printf("call to function\n"); }

    // error 1
    rv return_void;
    // error 2
    //static constexpr auto return_void = []{ printf("call to lambda\n");};
    void unhandled_exception() const noexcept {}
};

template <> struct std::coroutine_traits<pt::handle_t>
    { using promise_type = pt; };

static pt::handle_t foo()
{ 
    co_return;
}

int main()
{
    foo();
}
---
<source>: In function 'pt::handle_t foo()':
<source>:38:5: error: call to non-function 'pt::return_void'
   38 |     co_return;
      |     ^~~~~~~~~
<source>:39:1: error: call to non-function 'pt::return_void'
   39 | }
      | ^

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

end of thread, other threads:[~2020-10-31 12:39 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-03 22:34 [Bug c++/95519] New: [coroutines] non-functions for promise_type::return_void not supported bruck.michael at gmail dot com
2020-06-04 20:11 ` [Bug c++/95519] " iains at gcc dot gnu.org
2020-06-26 11:40 ` cvs-commit at gcc dot gnu.org
2020-06-26 13:05 ` bruck.michael at gmail dot com
2020-06-26 13:07 ` iains at gcc dot gnu.org
2020-06-26 13:18 ` iains at gcc dot gnu.org
2020-06-28 10:49 ` cvs-commit at gcc dot gnu.org
2020-06-29 11:49 ` cvs-commit at gcc dot gnu.org
2020-06-30 12:49 ` iains at gcc dot gnu.org
2020-10-31  2:45 ` hjl.tools at gmail dot com
2020-10-31  7:53 ` iains at gcc dot gnu.org
2020-10-31 12:39 ` hjl.tools at gmail dot com

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).