Boost logo

Boost :

Subject: Re: [boost] interest in a stateful pointer library?
From: Hans Dembinski (hans.dembinski_at_[hidden])
Date: 2017-10-09 12:06:07


Hi Glen,

> On 9. Oct 2017, at 13:42, Glen Fernandes via Boost <boost_at_[hidden]> wrote:
>
> On Mon, Oct 9, 2017 at 5:32 AM, Hans Dembinski wrote:
>> Please have a look at the updated README on Github. tagged_ptr uses
>> Boost.Align to get pointers with a special bit pattern which allows to
>> perfectly predict these bits and therefore use them to hold state. I thought
>> that this trick was platform-independent, since Boost.Align seems platform-
>> independent, but smart people on Reddit showed me that I am relying on
>> undefined behaviour here. It turns out that the conversion between
>> memory address and integers may not be as trivial as it is on a x86
>> machine, and then this trick would fail.
>
> If you're referring to the implementation of boost::alignment::align,
> it is platform-dependent. i.e. That is one of the reasons we wanted it
> in a Boost library: So that if there is a C++ implementation which
> requires a different platform-dependent solution, then
> boost::alignment::align will be updated to support that too.

ok, thanks for clarifying this. I understood that, but I was not very clear in my statement. AFAIU, Boost.Align also has a fall-back solution for unsupported systems, where more memory is allocated than necessary to assure the alignment. In that sense the library is "platform-independent" in that it would always do what it is supposed to do, although perhaps not as efficiently as possible.

Best regards,
Hans


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