C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Make all data pointers intercompatible

From: Jens Maurer <jens.maurer_at_[hidden]>
Date: Wed, 29 Jan 2025 17:58:46 +0100
On 29/01/2025 17.42, organicoman wrote:
> Let's take step by step.
>
> Can we agree that the following is true always?
>
> char* ptr;
> The least significant nibble of 'ptr' can be any value in {0,1,2,3,4,5,6,7,8}
>
> char** c_ptr = &ptr;
> The least significant nibble of 'c_ptr' can have only 2 values : {0, alignof(void*)}
>
> The former is to be able to index any item of a char array.
> And the later depends on the platform.
>
> Since the later is alway guaranteed, then we can use some N lower bits (which are always 0), to store a bit tag.

Trying to do so is challenging, because those modified pointers
will be invalid pointer values per the taxonomy in [basic.compound] p3.
See also [basic.compound] p4 and [conv.lval] p3.3.

Jens

Received on 2025-01-29 16:58:49