Boost logo

Boost :

Subject: [boost] [interprocess] weirdest bug with offset_ptr equality comparison
From: Joaquin M López Muñoz (joaquinlopezmunoz_at_[hidden])
Date: 2016-08-08 14:02:05


The following is a distilled testcase after the ticket reported at

https://svn.boost.org/trac/boost/ticket/12367

   #include <boost/interprocess/allocators/allocator.hpp>
   #include <boost/interprocess/managed_shared_memory.hpp>

   template<typename Allocator>
   struct node_base
   {
     using allocator_type=Allocator;
   };

   template<typename Allocator>
   struct node_impl
   {
     using value_type=
       typename Allocator::template rebind<node_impl>::other::value_type;
   };

   template<typename Super>
   struct trampoline:node_impl<typename Super::allocator_type>{};

   template<typename Super>
   struct node:Super,trampoline<Super>{};

   int main()
   {
     using node_type=
       node<
         node<
           node_base<
             boost::interprocess::allocator<
               int,
boost::interprocess::managed_shared_memory::segment_manager
>
>
>
>;
     using pointer=boost::interprocess::offset_ptr<node_type>;

     pointer p=nullptr;
     bool b=(p==p); // here's the problem
   }

This works fine with GCC. When compiled with Visual Studio 2015, we get:

1>------ Build started: Project: borrame2015, Configuration: Debug x64
------
1> sandbox.cpp
1>d:\usr\joaquin\proyectos\boost-repo\trunk\boost\interprocess\detail\mpl.hpp(74):
error C2594: 'argument': ambiguous conversions from
'node<node<node_base<boost::interprocess::allocator<int,boost::interprocess::segment_manager<CharType,MemoryAlgorithm,IndexType>>>>>
' to
'node_impl<boost::interprocess::allocator<int,boost::interprocess::segment_manager<CharType,MemoryAlgorithm,IndexType>>>
'
1> with
1> [
1> CharType=char,
1>
MemoryAlgorithm=boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family,boost::interprocess::offset_ptr<void,ptrdiff_t,size_t,0x00>,0x00>,
1> IndexType=boost::interprocess::iset_index
1> ]
1> d:\usr\joaquin\proyectos\borrame2015\sandbox.cpp(39): note: see
reference to class template instantiation
'boost::interprocess::ipcdetail::is_convertible<node_type *,PointedType
*>' being compiled
1> with
1> [
1>
PointedType=node_impl<boost::interprocess::allocator<int,boost::interprocess::segment_manager<char,boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family,boost::interprocess::offset_ptr<void,ptrdiff_t,size_t,0x00>,0x00>,boost::interprocess::iset_index>>>
1> ]
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Note that it is the line

     bool b=(p==p); // here's the problem

that triggers the problem; if removed, compilation goes fine. Almost
anything in the
testcase program is needed for the problem to arise:

   - using node_type=node<node<...>> --> using node_type=node<...>
(just one node
     level): compilation OK
   - remove using value_type=... in node_impl: compilation OK
   - rebind<node_mpl> --> rebind<char>: compilation OK
   - use std::allocator rather than boost::interprocess::allocator:
compilation OK

Ion, I'm totally puzzled by this and unable to navigate through the
internals
of Boost.Interprocess. Totally at your disposal if you need further info
or assistance
running tests etc.

Thank you,

Joaquín M López Muñoz


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk