Title
Incorrect "mixed" move-assignment semantics of unique_ptr
Status
c++14
Section
[unique.ptr.single.asgn]
Submitter
Daniel Krügler

Created on 2011-04-16.00:00:00 last changed 123 months ago

Messages

Date: 2011-08-16.10:45:53

Proposed resolution:

This wording is relative to the FDIS.

  1. Edit [unique.ptr.single.asgn] p. 6 as indicated:

    template <class U, class E> unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept;
    

    4 - Requires: If E is not a reference type, assignment of the deleter from an rvalue of type E shall be well-formed and shall not throw an exception. Otherwise, E is a reference type and assignment of the deleter from an lvalue of type E shall be well-formed and shall not throw an exception.

    5 - Remarks: This operator shall not participate in overload resolution unless:

    • unique_ptr<U, E>::pointer is implicitly convertible to pointer and
    • U is not an array type.

    6 - Effects: Transfers ownership from u to *this as if by calling reset(u.release()) followed by an assignment from std::forward<DE>(u.get_deleter()).

    7 - Returns: *this.

Date: 2011-08-16.10:45:53

[ Bloomington, 2011 ]

Move to Ready

Date: 2011-04-20.20:04:18

The semantics described in [unique.ptr.single.asgn] p. 6

Effects: Transfers ownership from u to *this as if […] followed by an assignment from std::forward<D>(u.get_deleter()).

contradicts to the pre-conditions described in p. 4:

Requires: If E is not a reference type, assignment of the deleter from an rvalue of type E shall be well-formed and shall not throw an exception. Otherwise, E is a reference type and assignment of the deleter from an lvalue of type E shall be well-formed and shall not throw an exception.

Either the pre-conditions are incorrect or the semantics should be an assignment from std::forward<E>(u.get_deleter()), instead.

It turns out that this contradiction is due to an incorrect transcription from the proposed resolution of 983 to the finally accepted proposal n3073 (see bullet 12) as confirmed by Howard Hinnant, thus the type argument provided to std::forward must be fixed as indicated.

History
Date User Action Args
2014-02-20 13:20:35adminsetstatus: wp -> c++14
2012-02-12 18:36:43adminsetstatus: voting -> wp
2012-02-09 04:07:48adminsetstatus: ready -> voting
2011-08-16 10:45:53adminsetmessages: + msg5837
2011-08-16 10:45:53adminsetstatus: new -> ready
2011-04-20 19:54:50adminsetmessages: + msg5723
2011-04-16 00:00:00admincreate