Boost logo

Boost :

Subject: Re: [boost] [interprocess] 32-bit offset_ptr
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2019-02-02 21:56:05


On 02/02/2019 18:19, Steven Watanabe via Boost wrote:
> AMDG
>
> On 2/2/19 9:28 AM, Phil Endecott via Boost wrote:
>> I have some old code that uses 32-bit offset_ptrs, i.e.
>>
>>   typedef boost::interprocess::offset_ptr<void, int32_t, int32_t> ptr_t;
>>
>> This has stopped working on 64-bit systems at some point since 1.58.
>> git blame
>> suggests a commit on  14 Oct 2015.  There is now a static assert that
>> checks that
>> OffsetType is at least as large as a raw pointer.
>>
>> In the current case, I'm using these pointers within memory-mapped files
>> which will
>> always be vastly smaller than the 32-bit limit.  Using 32-bit offsets
>> seemed
>> like a worthwhile optimisation at the time, and now I am hoping to maintain
>> binary compatibility with those files.
>>
>
> The offset_ptr is not restricted to existing inside
> the memory-mapped file. The library can and
> does create temporaries.

Correct. An offset_ptr placed in the stack (a temporary, a return or
argument in a function) must be able to point to an object in shared
memory. Thus in 64 bit address-spaces a 64-bit offset is needed.

Best,

Ion


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