Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile Error When Wrapping Receiver by Derivation #1408

Open
RobertLeahy opened this issue Aug 31, 2024 · 0 comments
Open

Compile Error When Wrapping Receiver by Derivation #1408

RobertLeahy opened this issue Aug 31, 2024 · 0 comments

Comments

@RobertLeahy
Copy link

Given:

template<::stdexec::receiver Receiver>
struct receiver : Receiver {
  template<typename T>
    requires std::constructible_from<Receiver, T>
  explicit constexpr receiver(T&& t) noexcept(
    std::is_nothrow_constructible_v<Receiver, T>)
    : Receiver(std::forward<T>(t))
  {}
};

template<::stdexec::sender Sender>
struct sender {
  using sender_concept = ::stdexec::sender_t;
  template<typename T>
    requires std::constructible_from<Sender, T>
  explicit constexpr sender(T&& t) noexcept(
    std::is_nothrow_constructible_v<Sender, T>)
    : sender_(std::forward<T>(t))
  {}
  template<typename Self, typename Env>
  ::stdexec::completion_signatures_of_t<
    decltype(std::declval<Self>().sender_),
    Env> get_completion_signatures(this Self&&, const Env&);
  template<typename Self, typename Receiver>
    requires ::stdexec::sender_to<
      Sender,
      receiver<std::remove_cvref_t<Receiver>>>
  auto connect(this Self&& self, Receiver&& r) noexcept(
    noexcept(
      ::stdexec::connect(
        std::declval<Self>().sender_,
        receiver<std::remove_cvref_t<Receiver>>(std::declval<Receiver>()))))
  {
    return ::stdexec::connect(
      std::forward<Self>(self).sender_,
      receiver<std::remove_cvref_t<Receiver>>(std::forward<Receiver>(r)));
  }
private:
  Sender sender_;
};

template<typename T>
explicit sender(T) -> sender<T>;

The following fails to compile (at least on GCC 14.1.0):

auto op = ::stdexec::connect(
  ::stdexec::just() | ::stdexec::let_value([]() {
    return sender(
      ::stdexec::just() | ::stdexec::then([]() noexcept {
        return 5;
      }));
  }),
  make_receiver([](auto&&...) noexcept {}));

Where the make_receiver invocation simply creates a receiver that accepts anything.

Internally the machinery seems to be confusing the derived type with the base type:

/scratch/mdx/src/../include/stdexec/__detail/__basic_sender.hpp:362:84: error: cannot convert ‘stdexec::__detail::__op_state<stdexec::__sexpr<<lambda closure object>stdexec::{anonymous}::<lambda()>(), stdexec::{anonymous}::__anon>, mdx::execution::tests::{anonymous}::receiver<stdexec::__any_::__receiver_ref<stdexec::completion_signatures<stdexec::__rcvrs::set_value_t(int)> > > >* const’ to ‘stdexec::__detail::__receiver<stdexec::__any_::__receiver_ref<stdexec::completion_signatures<stdexec::__rcvrs::set_value_t(int)> >, stdexec::__sexpr<<lambda closure object>stdexec::{anonymous}::<lambda()>(), stdexec::{anonymous}::__anon>, stdexec::__muchar (*)[1]>::__t::__parent_op_t*’ {aka ‘stdexec::__detail::__op_state<stdexec::__sexpr<<lambda closure object>stdexec::{anonymous}::<lambda()>(), stdexec::{anonymous}::__anon>, stdexec::__any_::__receiver_ref<stdexec::completion_signatures<stdexec::__rcvrs::set_value_t(int)> > >*’} in initialization
  362 |           return __tuple{connect(static_cast<_Child&&>(__child), __receiver_t<_Is>{__op_})...};
      |                                                                                    ^~~~~
      |                                                                                    |
      |                                                                                    stdexec::__detail::__op_state<stdexec::__sexpr<<lambda closure object>stdexec::{anonymous}::<lambda()>(), stdexec::{anonymous}::__anon>, mdx::execution::tests::{anonymous}::receiver<stdexec::__any_::__receiver_ref<stdexec::completion_signatures<stdexec::__rcvrs::set_value_t(int)> > > >* const

Full compilation output attached.

build.log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant