Why casting float* pFloat = (float*)&intVal; violates the C/C++ Strict Aliasing Rule:
The standard states that two pointers of different types cannot point to the same memory location (with exceptions for char* and std::byte*). If violated, the compiler optimizer assumes writes through pFloat do not affect reads from intVal, causing silent reordering bugs under -O2/-O3.
The Safe Modern Solution in C++20:
#include <bit>
float f = std::bit_cast<float>(intVal); // 100% standard-compliant zero-copy bit reinterpret!