int a;
auto *pa = reinterpret_cast<unsigned long long*>(&a);
*pa = 10;
int and unsigned long long types have different size. Does this code produce undefined behaviour?
int a;
auto *pa = reinterpret_cast<unsigned long long*>(&a);
*pa = 10;
int and unsigned long long types have different size. Does this code produce undefined behaviour?
Does access to int via pointer to unsigned long long cause UB?
Yes. The behaviour of the program is undefined.
int and unsigned long long types have different size.
The behaviour would be undefined even if the sizes were the same.