Opened 6 years ago

Closed 6 years ago

#12367 closed Bugs (fixed)

Using an offset_ptr type as value for multi_index_container causes compile error with 1.59+

Reported by: Michael Watkins <michael.watkins2@…> Owned by: Joaquín M López Muñoz
Milestone: To Be Determined Component: multi_index
Version: Boost 1.59.0 Severity: Showstopper
Keywords: multi_index multi_index_container interprocess offset_ptr Cc: ron.hall@…

Description

Our project uses multi_index_container in a Boost interprocess shared memory segment. This has always compiled fine until we tried upgrading to from 1.58 to 1.61. It turns out that something introduced in 1.59 causes a compile error.

Our code uses a boost::interprocess::offset_ptr as the value for a multi_index_container instantiated in the shared memory segment. Apparently anything with 1.59 or higher does not like this.

This has only been seen compiling with Visual Studio 2013.

I have attached the slightly modified boost example that causes the error and the error output.

Attachments (2)

boosttest.cpp (6.2 KB ) - added by Michael Watkins <michael.watkins2@…> 6 years ago.
Example that causes the compile error, slightly modified from the boost multi_index/interprocess interoperability example.
20160801 boosttest compile error.txt (40.1 KB ) - added by Michael Watkins <michael.watkins2@…> 6 years ago.
The compile error caused by the boosttest.cpp example.

Download all attachments as: .zip

Change History (7)

by Michael Watkins <michael.watkins2@…>, 6 years ago

Attachment: boosttest.cpp added

Example that causes the compile error, slightly modified from the boost multi_index/interprocess interoperability example.

by Michael Watkins <michael.watkins2@…>, 6 years ago

The compile error caused by the boosttest.cpp example.

comment:1 by Joaquín M López Muñoz, 6 years ago

Hi Michael,

Sorry about my late answering, I wasn't monitoring the email inbox these tickets notify to.

As for your problem, I think it is a rather obscure bug having to do with boost::interprocess:offset_ptr convertibility machinery. I'll try to isolate this into something I can go with to Boost.Interprocess's author. In the meantime, please try replacing line 37 of boost/multi_index/detail/raw_ptr.hpp:

  return p==Pointer(0)?0:&*p;

with

  return !p?0:&*p;

Could you please report back if this solves your problem? Thanks for spotting this bug.

Last edited 6 years ago by Joaquín M López Muñoz (previous) (diff)

comment:2 by Michael Watkins <michael.watkins2@…>, 6 years ago

Hi Joaquin:

The above change to replace line 37 does indeed fix the compile problem.

Thanks for your help!

comment:3 by Joaquín M López Muñoz, 6 years ago

Hi again,

Ion (the author of Boost.Container) has applied the following commit:

https://github.com/boostorg/interprocess/commit/8253c1b0add95ade098ae2d481f52a3bd4be6da5

Would you mind verifying if this (without my patch above) solves the problem so that we can close the ticket? Thank you,

comment:4 by Michael Watkins <michael.watkins2@…>, 6 years ago

Hello Joaquin:

Ion's fix works perfectly (verified without your above patch). Thanks to both of you for all your help!

comment:5 by Joaquín M López Muñoz, 6 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.