C++ Logo

std-proposals

Advanced search

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

From: Jens Maurer <jens.maurer_at_[hidden]>
Date: Tue, 28 Jan 2025 16:40:07 +0100
On 28/01/2025 16.29, Frederick Virchanza Gotham via Std-Proposals wrote:
> On Tue, Jan 28, 2025 at 3:16 PM organicoman wrote:
>>
>> The resulting pointer is unspecified: means dereferencing it is UB.
>> Because the compiler is not allowed to alter the bits of A. It will keep it as given.
>>
>> I can do the following.
>>
>> double* ptr = reinterpret_cast<double*>(0x7fff934a9d83); // misaligned for double
>>
>> ptr value will stay 0x7fff934a9d83, but it is unusable otherwise:
>> *ptr is UB
>> ++ptr is UB
>> --ptr is UB
>> ptr+int the result is UB.
>> ...etc
>
>
> I want the C++26 Standard to say that [...]

The end of the Hagenberg meeting is the deadline for
forwarding new features from EWG to CWG.
The pre-meeting mailing was the deadline for submitting new
proposals to EWG.

> double *ptr = reinterpret_cast<double*>(0x7fff934a9d83);
>
> Then I want "++ptr" to add 8 to it, giving 0x7FFF934A9D8B. I want this
> to be well-defined behaviour.

It is an important optimizer assumption that all values
of a given type "pointer to T" are suitably aligned for "T".

If you wish to change that, please submit a paper to EWG.
Oh, you missed the deadline for C++26, so please spend extra
rationale on why this particular feature is so important
that an exception to P1000 is warranted.

Jens

Received on 2025-01-28 15:40:11