Do I understand C/C++ strict-aliasing correctly?
I've read this article about C/C++ strict aliasing . I think the same applies to C++. As I understand, strict aliasing is used to rearrange the code for performance optimization. That's why two pointers of different (and unrelated in C++ case) types cannot refer to the same memory location. Does this mean that problems can occur only if memory is modified? Apart of possible problems with memory alignment . For example, handling network protocol, or de-serialization. I have a byte array, dynamically allocated and packet struct is properly aligned. Can I reinterpret_cast it to my packet struct?