Date: Tue, 28 Jan 2025 15:36:51 +0100
According to CPP Reference this is currently not okay:
"If expression represents the address A of a byte in memory but A does not satisfy the alignment requirement of T, then the resulting pointer value is unspecified."
https://en.cppreference.com/w/cpp/language/static_cast
-----Ursprüngliche Nachricht-----
Von:organicoman via Std-Proposals <std-proposals_at_[hidden]>
No it could not, and it is not allowed. The only thing you will MAYBE get is a misaligned pointer to a double memory location, and you should not dereference that pointer, because of aliasing incompatibility otherwise UB.
Try the following code:
#include <stdio.h>
int main()
{
char arr[8];
double* ptr = static_cast<double*>(static_cast<void*>(arr+3));
Received on 2025-01-28 14:40:26