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

   #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=
     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
error C2594: 'argument': ambiguous conversions from
' to
1> with
1> [
1> CharType=char,
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> ]
========== 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
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, gregod at, cpdaniel at, john at