[Boost-bugs] [Boost C++ Libraries] #10798: boost::movelib::unique_ptr resolves typedef pointer with the deletor's

Subject: [Boost-bugs] [Boost C++ Libraries] #10798: boost::movelib::unique_ptr resolves typedef pointer with the deletor's
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-11-17 12:39:22


#10798: boost::movelib::unique_ptr resolves typedef pointer with the deletor's
-------------------------------------------------+-------------------------
 Reporter: Matteo Settenvini | Owner: igaztanaga
  <matteo.settenvini@…> | Status: new
     Type: Bugs | Component: move
Milestone: To Be Determined | Severity: Problem
  Version: Boost 1.57.0 |
 Keywords: |
-------------------------------------------------+-------------------------
 Hello,

 as part of a project which entails adding some sort of virtuality in
 shared memory, we are using {{{boost::interprocess::unique_ptr}}}
 extensively; this, starting from 1.57.0, maps directly to
 {{{boost::movelib::unique_ptr}}}.

 I am providing a short example that exposes the problem (see attachment).

 We use a generic deleter which is non-virtual and takes a pointer to a
 common base class for destruction+deallocation with a custom allocator.
 The deleter must have a "{{{typedef ... pointer}}}" member, since it needs
 to work also with {{{boost::interprocess::shared_ptr}}}.

 However, the current implementation of unique_ptr has also a member
 "{{{typedef pointer}}}" which indirectly resolves to Deleter::pointer.
 That means that {{{unique_ptr<Derived>::pointer}}} ≡
 {{{Deleter::pointer}}} ≡ {{{Base}}}.

 Since e.g. {{{unique_ptr::operator->()}}} or {{{unique_ptr::get()}}} have
 a return type of type "{{{pointer}}}", each use of them effectively
 returns a pointer to the base class, which then needs manual static or
 dynamic casting.

 I am providing also the patch we are currently using to work around the
 issue. Of course, this is just a quick hack and not suitable for Boost,
 but it helps to pinpoint the problem.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10798>
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-02-16 18:50:17 UTC