Opened 6 years ago

Closed 6 years ago

#12920 closed Bugs (fixed)

movelib::unique_ptr: incorrect pointer type for nested array

Reported by: mkuron Owned by: Ion Gaztañaga
Milestone: To Be Determined Component: move
Version: Boost 1.63.0 Severity: Problem
Keywords: Cc:

Description

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.

Change History (1)

comment:1 by Ion Gaztañaga, 6 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.