Date: Mon, 27 Jan 2025 14:54:46 +0300
On 1/27/25 14:52, Andrey Semashev wrote:
> On 1/27/25 13:34, Frederick Virchanza Gotham via Std-Proposals wrote:
>> Tiago wrote:
>>>
>>> So what is the point of this?
>>
>> I want C++26 to explicitly state: "All pointer types are
>> intercompatible -- they all have the same size and representation",
>> which would allow code like:
>>
>> char c;
>> long double *p = &c;
>> char *p2 = p;
>> *p2 = 'a';
>>
>> The main use for this would be in allowing data to be misaligned in
>> memory.
>
> That doesn't follow. Practically speaking, pointers are currently
> "intercompatible", as you define it above(*), but that doesn't mean the
> data is allowed to be misaligned.
(*) on currently widely used targets.
> And proper data alignment is an important requirement regardless of
> pointer representation. It has significant performance and correctness
> implications. Relaxing this requirement (by default, barring some
> exceptions like intrinsics) is a wrong thing to do and IMO never going
> to happen.
>
> On 1/27/25 13:34, Frederick Virchanza Gotham via Std-Proposals wrote:
>> Tiago wrote:
>>>
>>> So what is the point of this?
>>
>> I want C++26 to explicitly state: "All pointer types are
>> intercompatible -- they all have the same size and representation",
>> which would allow code like:
>>
>> char c;
>> long double *p = &c;
>> char *p2 = p;
>> *p2 = 'a';
>>
>> The main use for this would be in allowing data to be misaligned in
>> memory.
>
> That doesn't follow. Practically speaking, pointers are currently
> "intercompatible", as you define it above(*), but that doesn't mean the
> data is allowed to be misaligned.
(*) on currently widely used targets.
> And proper data alignment is an important requirement regardless of
> pointer representation. It has significant performance and correctness
> implications. Relaxing this requirement (by default, barring some
> exceptions like intrinsics) is a wrong thing to do and IMO never going
> to happen.
>
Received on 2025-01-27 11:54:49