Probably even an implementation is compliant, where the address bits are reversed MSB=LSB compared to arithmetic types.
As long as &p[1] == p + 1
AFAIK there is no guarantee by the standard that the memory order is the same as the arithmetic order. E.g. when casting the pointer representation into an integer.
-----Ursprüngliche Nachricht-----
Von: organicoman via Std-Proposals <std-proposals@lists.isocpp.org>
Gesendet: Di 28.01.2025 19:26
Betreff: Re: [std-proposals] Make all data pointers intercompatible
An: Andrey Semashev via Std-Proposals <std-proposals@lists.isocpp.org>;
CC: organicoman <organicoman@yahoo.fr>;
>No, not "only". An implementation that e.g. >masks out the least
>significant bits of void* on conversion to T*, >according to T's
>alignment requirements, is possible.This will violate the strict aliasing rule. And any type can alias any type.>Another implementation that e.g.
>modifies tag bits in the pointer according to T >(e.g. to distinguish
>between pointed types in hardware to >improve security) is also possible.This is counter intuitive, because you will get a page of unsecured memory with some cells tagged as secured, or the opposite which is worse.Manipulating bits of a pointer should be a programmer responsibility, not the implementation.>Can you point where this is specified in the >standard?In the definition of the pointer type itself as a fundamental type.a pointer as a type defines 5 operations:++ increment, -- decrement, +ptr_diff_t add an offset, * dereference, (T*) castingNone manipulate bits.Sent from my GalaxyOn 1/28/25 20:51, organicoman wrote:-------- Original message --------From: Andrey Semashev via Std-Proposals <std-proposals@lists.isocpp.org>Date: 1/28/25 6:58 PM (GMT+01:00)To: Andrey Semashev via Std-Proposals <std-proposals@lists.isocpp.org>Cc: Andrey Semashev <andrey.semashev@gmail.com>Subject: Re: [std-proposals] Make all data pointers intercompatible
> The following
> T* => void* => U* => void* => T*
>
> Doesn't hold only in one case, when
> sizeof(U*) != sizeof(T*),
No, not "only". An implementation that e.g. masks out the least
significant bits of void* on conversion to T*, according to T's
alignment requirements, is possible. Another implementation that e.g.
modifies tag bits in the pointer according to T (e.g. to distinguish
between pointed types in hardware to improve security) is also possible.
> Which makes the conversion truncates bytes to fit the value inside the
> smaller size.(like from int to short)
> But it is always deterministic to guess the final value from the
> original value, that is to say , there is no manipulation of individual
> bits, especially the lowest ones.
Can you point where this is specified in the standard?
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals-- Std-Proposals mailing list Std-Proposals@lists.isocpp.org https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals