Skip to content

when_all's receiver's environment is incorrectly forwarding all queries #315

Open
@ericniebler

Description

@ericniebler

[exec.when.all] p6 reads:

  1. The member impls-for<when_all_t>::get-env is initialized with a callable object
    equivalent to the following lambda expression:

    []<class State, class Rcvr>(auto&&, State& state, const Receiver& rcvr) noexcept {
      return see below;
    }

    Returns an object e such that

    1. decltype(e) models queryable, and

    2. e.query(get_stop_token) is expression-equivalent to state.stop-src.get_token(), and

    3. given a query object q with type other than cv stop_token_t, e.query(q) is
      expression-equivalent to get_env(rcvr).query(q).

The problem is in (6.3). It should be forwarding on forwarding-query's to get_env(rcvr) but it is instead forwarding all queries.

Proposed resolution:

Change [exec.snd.expos] p2 as follows (underlined text is new):

  1. For a queryable object env, FWD-ENV(env) is an expression whose
    type satisfies queryable such that for a query object q and a pack
    of subexpressions as, the expression FWD-ENV(env).query(q, as...)
    is ill-formed if forwarding_query(q) is false; otherwise, it is
    expression-equivalent to env.query(q, as...).
    The type FWD-ENV-T(Env) is decltype(FWD-ENV(declval<Env>())).

Change [exec.when.all] para 6 as follows:

  1. given a query object q with type other than cv stop_token_tand whose type satisfies
    forwarding-query
    , e.query(q) is expression-equivalent to get_env(rcvr).query(q).

Change the definition of make-state in [exec.when.all] para 7 as follows:

 template<class Rcvr>
 struct make-state {
-  template<max-1-sender-in<env_of_t<Rcvr>>... Sndrs>
+  template<max-1-sender-in<FWD-ENV-T(env_of_t<Rcvr>)>... Sndrs>

Change para 9 as follows:

  1. The alias values_tuple denotes the type

    -tuple<value_types_of_t<Sndrs, env_of_t<Rcvr>, decayed-tuple, optional>...>
    +tuple<value_types_of_t<Sndrs, FWD-ENV-T(env_of_t<Rcvr>), decayed-tuple, optional>...>

    if that type is well-formed; otherwise, tuple<>.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1bugSomething isn't workingpending-wg21A paper or an LWG issue exits

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions