[Boost-bugs] [Boost C++ Libraries] #12920: movelib::unique_ptr: incorrect pointer type for nested array

Subject: [Boost-bugs] [Boost C++ Libraries] #12920: movelib::unique_ptr: incorrect pointer type for nested array
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-03-21 09:49:09


#12920: movelib::unique_ptr: incorrect pointer type for nested array
------------------------------+------------------------
 Reporter: mkuron | Owner: igaztanaga
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: move
  Version: Boost 1.63.0 | Severity: Problem
 Keywords: |
------------------------------+------------------------
 When attempting to use {{{boost::movelib::unique_ptr}}} to store an array
 of, for example, {{{double[2]}}}, the type of the contained pointer ends
 up being {{{double *}}} instead of {{{double (*)[2]}}}, resulting in
 conversion errors and the inability to use
 {{{boost::movelib::unique_ptr}}} for this purpose. {{{std::unique_ptr}}}
 behaves as expected, so evidently Boost's implementation does not fully
 match the standard one. It seems like {{{remove_extent}}} is used one too
 many times. Below is a short example:


 {{{
 #include <memory>
 #include <functional>
 #include <boost/move/unique_ptr.hpp>

 using boost::movelib::unique_ptr;

 typedef double C[2];

 static_assert(std::is_same<unique_ptr<C[]>::pointer, C*>::value, "Pointer
 types must match");
 static_assert(std::is_same<unique_ptr<C[]>::element_type, C>::value,
 "Element types must match");

 int main() {
   unique_ptr<C[], std::function<void(C *)> > p1;
   unique_ptr<C[]> p2;

   return 0;
 }
 }}}
 Replace line 5 with {{{using std::unique_ptr}}} to see that it works with
 the standard library's unique_ptr.
 Interestingly, as seen by the {{{static_assert}}}, only {{{pointer}}} has
 the wrong type; {{{element_type}}} is correct.


 Tested with Boost 1.59 and 1.63 with Xcode 8.2.1 on Mac OS X 10.12 and GCC
 6 on Linux.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/12920>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-03-21 09:52:10 UTC