[Bug c++/94760] New: coroutines: mismatch between traits and promise parameter preview.

iains at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Apr 25 14:54:06 GMT 2020


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

            Bug ID: 94760
           Summary: coroutines: mismatch between traits and promise
                    parameter preview.
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: iains at gcc dot gnu.org
  Target Milestone: ---

Created attachment 48374
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48374&action=edit
fix under test

There was considerable confusion about how the various implementations
had interpreted the passing of 'this' and lambda capture object
pointers to traits lookup and the promise methods (constructor and
allocator)

In response, we changed the argument passed to the promise parameter
preview to match a reference to *this.  That has made things inconsistent
and we need to match it in the traits

the following code should compile, but fails unable to find a suitable
promise CTOR.

====

struct Fake {} ;

template<typename R, typename CallOp, typename ...T>
struct std::coroutine_traits<R, CallOp, T...> {
    struct promise_type {
        promise_type (CallOp op, T ...args) {}
        Fake get_return_object() { return {}; }
        std::suspend_always initial_suspend() { return {}; }
        std::suspend_never final_suspend() { return {}; }
        void return_void() {}
        void unhandled_exception() {}
    };
};


struct Foo
{
  Fake operator() (int a) {
    co_return;
  }
};


More information about the Gcc-bugs mailing list