Opened 8 years ago

Closed 8 years ago

#10011 closed Bugs (fixed)

segment_manager::find( unique_instance_t* ) fails to compile

Reported by: Michael Smolensky <smolensky@…> Owned by: Ion Gaztañaga
Milestone: To Be Determined Component: interprocess
Version: Boost 1.55.0 Severity: Problem
Keywords: Cc:

Description

When called directly (not from managed_memory_impl), segment_manager::find( unique_instance_t* ) fails to compile. Both v 1.53, 1.55, and 1.55b have this issue.

The fix would be either:

  • to remove segment_manager::find( unique_instance_t* ) and replace

find( const CharType* ) with find( char_ptr_holder_t ) or

  • to fix priv_find_impl( unique_instance* ): in line 742 replace name with typeid(T).name()

void *ret = priv_generic_find<char>(name, m_header.m_unique_index, table, size, is_intrusive_t(), lock);

with

void *ret = priv_generic_find<char>(typeid(T).name(), m_header.m_unique_index, table, size, is_intrusive_t(), lock);

Below is a test program and VC11 error:

#include <boost/interprocess/indexes/flat_map_index.hpp>
#include <boost/interprocess/mem_algo/simple_seq_fit.hpp>
#include <boost/interprocess/mapped_region.hpp>
#include <boost/interprocess/segment_manager.hpp>
#include <boost/interprocess/shared_memory_object.hpp>
#include <boost/interprocess/sync/mutex_family.hpp>

int main()
{
  using namespace boost::interprocess;

  typedef simple_seq_fit< null_mutex_family >                AllocAlgo;
  typedef segment_manager< char, AllocAlgo, flat_map_index > MemManager;

  shared_memory_object sh_mem( create_only, "test", read_write );
  sh_mem.truncate( 1000 );
  mapped_region mapping( sh_mem, read_write );

  MemManager* mem_mgr = new( mapping.get_address() ) MemManager( 1000 );
  mem_mgr->construct< int >( unique_instance );
  int* p = mem_mgr->find< int >( unique_instance ).first;

  return 0;
}

1> main.cpp 1>c:\dev\exb++.libs\boost\1.55.0b0\common\include\boost\interprocess\segment_manager.hpp(430): error C2664: 'std::pair<_Ty1,_Ty2> boost::interprocess::segment_manager<CharType,MemoryAlgorithm,IndexType>::priv_find_impl<T>(const CharType *,bool)' : cannot convert parameter 1 from 'const boost::interprocess::ipcdetail::unique_instance_t *' to 'const char *' 1> with 1> [ 1> _Ty1=int *, 1> _Ty2=unsigned int, 1> CharType=char, 1> MemoryAlgorithm=AllocAlgo, 1> IndexType=boost::interprocess::flat_map_index, 1> T=int 1> ] 1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 1> c:\prj\boostinterprocess\main.cpp(21) : see reference to function template instantiation 'std::pair<_Ty1,_Ty2> boost::interprocess::segment_manager<CharType,MemoryAlgorithm,IndexType>::find<int>(const boost::interprocess::ipcdetail::unique_instance_t *)' being compiled 1> with 1> [ 1> _Ty1=int *, 1> _Ty2=unsigned int, 1> CharType=char, 1> MemoryAlgorithm=AllocAlgo, 1> IndexType=boost::interprocess::flat_map_index 1> ] 1> c:\prj\boostinterprocess\main.cpp(21) : see reference to function template instantiation 'std::pair<_Ty1,_Ty2> boost::interprocess::segment_manager<CharType,MemoryAlgorithm,IndexType>::find<int>(const boost::interprocess::ipcdetail::unique_instance_t *)' being compiled 1> with 1> [ 1> _Ty1=int *, 1> _Ty2=unsigned int, 1> CharType=char, 1> MemoryAlgorithm=AllocAlgo, 1> IndexType=boost::interprocess::flat_map_index 1> ]

Change History (1)

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

Resolution: fixed
Status: newclosed

Thanks for the report. Fixed in:

[develop aa09229] Fixes #10011 segment_manager::find( unique_instance_t* ) fails to compile

9 files changed, 692 insertions(+), 101 deletions(-) create mode 100644 proj/vc7ide/segment_manager_test.vcproj create mode 100644 test/segment_manager_test.cpp

Note: See TracTickets for help on using tickets.