Opened 9 years ago

Closed 9 years ago

Last modified 9 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: Ion Gaztañaga
Milestone: To Be Determined Component: interprocess
Version: Boost 1.54.0 Severity: Problem
Keywords: Cc:

Description

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 {
   public:
      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@…> 9 years ago.
quick hack

Download all attachments as: .zip

Change History (6)

comment:1 by Markus Mathes <Markus.Mathes@…>, 9 years ago

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);

by Markus Mathes <Markus.Mathes@…>, 9 years ago

quick hack

comment:2 by Markus Mathes <Markus.Mathes@…>, 9 years ago

Another workaround ist to use:

boost::interprocess:shared_ptr<int,container::outermost_allocator<Allocator>::type,MyDeleter>

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

comment:3 by Ion Gaztañaga, 9 years ago

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

comment:4 by Ion Gaztañaga, 9 years ago

Resolution: fixed
Status: newclosed

(In [85587]) Fixes #8976

comment:5 by Markus.Mathes@…, 9 years ago

Thanks for fixing!

Note: See TracTickets for help on using tickets.