C++ Logo

std-discussion

Advanced search

Re: Alignment and addresses

From: Timur Doumler <cpp_at_[hidden]>
Date: Thu, 6 Jul 2023 17:55:19 +0300
Hi,

> On 6 Jul 2023, at 01:55, Bernhard Manfred Gruber via Std-Discussion <std-discussion_at_[hidden]> wrote:
> For that matter, values of type double could be allocated at the addresses 0x1, 0x9, 0x11, 0x19, etc.

This is correct. This is why we had to standardise std::assume_aligned as a separate feature from [[assume(expression)]]: because the statement "this pointer is aligned with N bytes" is inexpressible as a C++ expression. Checking for modulo N does not work because of the way it's specified. It works in practice on every modern platform I am aware of, but it is not required to do so.

Cheets,
Timur

Received on 2023-07-06 14:55:24