Date
2018-02-26.00:00:00
Message id
9702

Content

Addresses: networking.ts

The DynamicBuffer overloads of async_read and async_write, and async_read_until, are underspecified with respect to the lifetime of the dynamic buffer argument b.

Asio's implementation (and the intended specification) performs DECAY_COPY(b) in the async_read, async_write, and async_read_until initiating functions. All operations performed on b are actually performed on that decay-copy, or on a move-constructed descendant of it. The copy is intended to refer to the same underlying storage and be otherwise interchangeable with the original in every way.

Most initiating functions' argument lifetimes are covered by [async.reqmts.async.lifetime]. As an rvalue reference it falls under the second bullet, which specifies that the object is copied (but doesn't say decay-copied).

The proposed resolution adds a postcondition for DynamicBuffer move construction, and specifies that DECAY_COPY(b) be used for each of these functions. The following two alternative resolutions may also be considered:

  • Add an extra bullet to [async.reqmts.async.lifetime] to cover rvalue parameters (but specifically exclude CompletionTokens).

  • Change the DynamicBuffer arguments to be by-value. (And also change the corresponding synchronous operations to be consistent.)

However, the proposed resolution below is presented as a change that minimizes the scope of the impact.