This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

4466. task should move its result

Section: 33.13.6.5 [task.promise] Status: New Submitter: Robert A.H. Leahy Opened: 2025-11-05 Last modified: 2025-11-08

Priority: Not Prioritized

View other active issues in [task.promise].

View all other issues in [task.promise].

View all issues with New status.

Discussion:

In 33.13.6.5 [task.promise] there's the following bullet (7.3):

set_value(std::move(RCVR(*this)), *result).

This has the effect of sending the result as an lvalue whereas an rvalue is almost certainly what's intended, see the bullet (7.1) above:

set_error(std::move(RCVR(*this)), std::move(e)) […]

Resolution would be to change the bullet (7.3) to:

set_value(std::move(RCVR(*this)), *std::move(result)).

[2025-11-07; This would be resolved by LWG 4339(i).]

Proposed resolution:

This wording is relative to N5014.

  1. Modify 33.13.6.5 [task.promise], as indicated:

    auto final_suspend() noexcept;
    

    -7- Returns: An awaitable object of unspecified type (7.6.2.4 [expr.await]) whose member functions arrange for the completion of the asynchronous operation associated with STATE(*this) by invoking:

    • (7.1) — set_error(std::move(RCVR(*this)), std::move(e)) if errors.index() is greater than zero and e is the value held by errors, otherwise
    • (7.2) — set_value(std::move(RCVR(*this))) if is_void<T> is true, and otherwise
    • (7.3) — set_value(std::move(RCVR(*this)), *std::move(result)).