Without knowing the programmer(s) who wrote that code in the first place, I doubt you can get a truly authoritative answer.
Here's my best guess: the authors didn't want to rely on a possible memcpy
optimization (which is in no way guaranteed by the spec, even if it is implemented by many compilers). On the flip side, writing a reinterpret_cast
is very, very likely to produce simply the unaligned access instruction that the authors were expecting, on practically any compiler.
While smart, modern compilers will optimize the memcpy
, older ones may not. Consistent performance can be quite critical to this library, so they seem to have sacrificed some correctness (since the reinterpret_cast
appears to be potentially UB) in favour of obtaining more consistent results across a wider set of compilers.