938. default_delete<T[]>::operator() should only accept T*

Section: 23.11.1.1.3 [unique.ptr.dltr.dflt1] Status: C++11 Submitter: Howard Hinnant Opened: 2008-12-07 Last modified: 2016-02-10

Priority: Not Prioritized

View all issues with C++11 status.

Discussion:

Consider:

derived* p = new derived[3];
std::default_delete<base[]> d;
d(p);  // should fail

Currently the marked line is a run time failure. We can make it a compile time failure by "poisoning" op(U*).

[ Post Summit: ]

Recommend Review.

[ Batavia (2009-05): ]

We agree with the proposed resolution. Move to Tentatively Ready.

Proposed resolution:

Add to 23.11.1.1.3 [unique.ptr.dltr.dflt1]:

namespace std {
  template <class T> struct default_delete<T[]> {
    void operator()(T*) const;
  template <class U> void operator()(U*) const = delete;
};
}