Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#8976 closed Bugs (fixed)

interprocess::shared_ptr fails to compile if used with a scoped_allocator

Reported by: Markus Mathes <Markus.Mathes@…> Owned by: igaztanaga
Milestone: To Be Determined Component: interprocess
Version: Boost 1.54.0 Severity: Problem
Keywords: Cc:


The following code will fail to compile using at least gcc 4.6.3

#include <memory>
#include <boost/container/scoped_allocator.hpp>
#include <boost/interprocess/smart_ptr/shared_ptr.hpp>
namespace bip=boost::interprocess;

int main(int argc, char* argv[]) {

   class MyDeleter {
      typedef std::allocator<void>::pointer pointer;
      void operator()(const pointer& ptr){};

   typedef boost::container::scoped_allocator_adaptor< std::allocator<void> > Allocator;
   Allocator alloc;

   // next line will fail to compile due to a inaccessible base type error
   bip::shared_ptr<int,Allocator::outer_allocator_type,MyDeleter> test1(new int(),alloc);

   //using the outer_allocator will work fine
   bip::shared_ptr<int,Allocator::outer_allocator_type,MyDeleter> test2(new int(),alloc);

Attachments (1)

interprocess_shared_ptr_scoped_alloc.patch (530 bytes) - added by Markus Mathes <Markus.Mathes@…> 4 years ago.
quick hack

Download all attachments as: .zip

Change History (6)

comment:1 Changed 4 years ago by Markus Mathes <Markus.Mathes@…>

Typo while copying the code. The line to fail must read:

// next line will fail to compile due to a inaccessible base type error
bip::shared_ptr<int,Allocator,MyDeleter> test1(new int(),alloc);

Changed 4 years ago by Markus Mathes <Markus.Mathes@…>

quick hack

comment:2 Changed 4 years ago by Markus Mathes <Markus.Mathes@…>

Another workaround ist to use:


to remove the scoped allocator capabilities which anyway are not needed ...

comment:3 Changed 4 years ago by igaztanaga

Thanks for the report, the problem was in the "destroy" function, where a proper static_cast was needed.

comment:4 Changed 4 years ago by igaztanaga

  • Resolution set to fixed
  • Status changed from new to closed

(In [85587]) Fixes #8976

comment:5 Changed 4 years ago by Markus.Mathes@…

Thanks for fixing!

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain igaztanaga.
The resolution will be deleted. Next status will be 'reopened'.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.