strict aliasing rule
The C++ rule that a pointer to one type may be assumed not to point at an object of an unrelated type, which lets the optimizer keep values in registers.
The strict aliasing rule ([basic.lval]) makes accessing an object through a glvalue of an unrelated type undefined behaviour, so the optimizer may assume an int* and a float* never refer to the same storage.
Examples
Reading a
float's bits through anint*is undefined;std::bit_cast<std::uint32_t>(f)orstd::memcpyis the defined way.
See also