Modify

Ticket #8976 (closed Bugs: fixed)

Opened 8 months ago

Last modified 7 months ago

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:

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

interprocess_shared_ptr_scoped_alloc.patch Download (530 bytes) - added by Markus Mathes <Markus.Mathes@…> 7 months ago.
quick hack

Change History

comment:1 Changed 8 months 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 7 months ago by Markus Mathes <Markus.Mathes@…>

quick hack

comment:2 Changed 7 months ago by Markus Mathes <Markus.Mathes@…>

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 Changed 7 months ago by igaztanaga

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

comment:4 Changed 7 months ago by igaztanaga

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

(In [85587]) Fixes #8976

comment:5 Changed 7 months ago by Markus.Mathes@…

Thanks for fixing!

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


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

 
Note: See TracTickets for help on using tickets.