Date: Tue, 28 Jan 2025 20:58:33 +0300
On 1/28/25 20:51, organicoman wrote:
> 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?
> 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?
Received on 2025-01-28 17:58:36