I recently learned that the C++ standard contains "strict aliasing rules", which forbid referencing the same memory location via variables of different types.
However, the standard does allows for char
types to legally alias any other type. Does this mean reinterpret_cast
may legally only be used to cast to type char *
or char &
?
I believe strict aliasing allows for casting between types in an inheritance hierarchy, but I think those situations would tend to use dynamic_cast<>?
Thank you