Created on 2008-11-26.00:00:00 last changed 171 months ago
Proposed resolution:
Change the description of the default constructor in [unique.ptr.single.ctor]:
unique_ptr();-1- Requires: D shall be default constructible, and that construction shall not throw an exception.
D shall not be a reference type or pointer type (diagnostic required)....
Remarks: The program shall be ill-formed if this constructor is instantiated when D is a pointer type or reference type.
Add after [unique.ptr.single.ctor]/8:
unique_ptr(pointer p);...
Remarks: The program shall be ill-formed if this constructor is instantiated when D is a pointer type or reference type.
Rationale:
Solved by N3073.
[ 2010-03-14 Howard adds: ]
We moved N3073 to the formal motions page in Pittsburgh which should obsolete this issue. I've moved this issue to NAD Editorial, solved by N3073.
[ 2009-10 Santa Cruz: ]
Moved to Ready.
[ 2009-08-17 Daniel adds: ]
It is insufficient to require a diagnostic. This doesn't imply an ill-formed program as of [defns.diagnostic] (a typical alternative would be a compiler warning), but exactly that seems to be the intend. I suggest to use the following remark instead:
Remarks: The program shall be ill-formed if this constructor is instantiated when D is a pointer type or reference type.
Via the general standard rules of [intro.compliance] the "diagnostic required" is implied.
[ 2009-07-27 Howard adds: ]
The two constructors to which this issue applies are not easily constrained with enable_if as they are not templated:
unique_ptr(); explicit unique_ptr(pointer p);To "SFINAE" these constructors away would take heroic effort such as specializing the entire unique_ptr class template on pointer deleter types. There is insufficient motivation for such heroics. Here is the expected and reasonable implementation for these constructors:
unique_ptr() : ptr_(pointer()) { static_assert(!is_pointer<deleter_type>::value, "unique_ptr constructed with null function pointer deleter"); } explicit unique_ptr(pointer p) : ptr_(p) { static_assert(!is_pointer<deleter_type>::value, "unique_ptr constructed with null function pointer deleter"); }I.e. just use static_assert to verify that the constructor is not instantiated with a function pointer for a deleter. The compiler will automatically take care of issuing a diagnostic if the deleter is a reference type (uninitialized reference error).
In keeping with our discussions in Frankfurt, I'm moving this requirement on the implementation from the Requires paragraph to a Remarks paragraph.
[ 2009-07 Frankfurt: ]
We need to consider whether some requirements in the Requires paragraphs of [unique.ptr] should instead be Remarks.
Leave Open. Howard to provide wording, and possibly demonstrate how this can be implemented using enable_if.
[ 2009-07 Frankfurt ]
Moved from Tentatively Ready to Open only because the wording needs to be improved for enable_if type constraining, possibly following Robert's formula.
[ Post Summit: ]
Recommend Tentatively Ready.
Addresses US 79
[unique.ptr.single.ctor]/5 no longer requires for D not to be a pointer type. I believe this restriction was accidently removed when we relaxed the completeness reuqirements on T. The restriction needs to be put back in. Otherwise we have a run time failure that could have been caught at compile time:
{ unique_ptr<int, void(*)(void*)> p1(malloc(sizeof(int))); // should not compile } // p1.~unique_ptr() dereferences a null function pointer unique_ptr<int, void(*)(void*)> p2(malloc(sizeof(int)), free); // ok
History | |||
---|---|---|---|
Date | User | Action | Args |
2010-11-19 19:04:45 | admin | set | status: nad editorial -> resolved |
2010-10-21 18:28:33 | admin | set | messages: + msg4438 |
2010-10-21 18:28:33 | admin | set | messages: + msg4437 |
2010-10-21 18:28:33 | admin | set | messages: + msg4436 |
2010-10-21 18:28:33 | admin | set | messages: + msg4435 |
2010-10-21 18:28:33 | admin | set | messages: + msg4434 |
2010-10-21 18:28:33 | admin | set | messages: + msg4433 |
2010-10-21 18:28:33 | admin | set | messages: + msg4432 |
2010-10-21 18:28:33 | admin | set | messages: + msg4431 |
2010-10-21 18:28:33 | admin | set | messages: + msg4430 |
2008-11-26 00:00:00 | admin | create |