Boost logo

Boost :

Subject: Re: [boost] interest in a stateful pointer library?
From: Arvid Norberg (arvid.norberg_at_[hidden])
Date: 2017-10-09 10:59:29


On Mon, Oct 9, 2017 at 11:37 AM, Peter Dimov via Boost <
boost_at_[hidden]> wrote:

> Hans Dembinski wrote:
>
> This is kinda sad, because the library is much less useful if tagged_ptr
>> is not guaranteed to work on all platforms now and in the future. Just
>> assume you use this in a large project and rely on it, and then a new
>> processor generation comes out where tagged_ptr does not work anymore. That
>> being said it is probably still useful for special projects, but not
>> something to put in Boost. :(
>>
>
> On the contrary, this is exactly why it needs to be put in Boost - to
> isolate the platform-specific differences behind a portable interface.
>
> but smart people on Reddit showed me that I am relying on undefined
>> behaviour here.
>>
>
> Out of curiosity, what's the specific problem that was pointed out? What
> behavior is undefined?
>

Without having read the reddit thread, I would expect this library to only
depend on *implementation defined* behavior. Namely the mapping of pointer
to integer conversions [1].

A pointer can be explicitly converted to any integral type large enough to
> hold it. The mapping function is implementation-defined.

[ Note: It is intended to be unsurprising to those who know the addressing
> structure of the underlying machine. — end note]

That note seem to indicate that only in the case of exotic hardware would
the assumptions about what aligned addresses look like be invalid.

-- 
Arvid Norberg
[1] http://eel.is/c++draft/expr#reinterpret.cast-4

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