I\'ve been using std::memcpy to circumvent strict aliasing for a long time.
For example, inspecting a float, like this:
Your example is well-defined and does not break strict aliasing. std::memcpy clearly states:
Copies
countbytes from the object pointed to by src to the object pointed to by dest. Both objects are reinterpreted as arrays ofunsigned char.
The standard allows aliasing any type through a (signed/unsigned) char* or std::byte and thus your example doesn't exhibit UB. If the resulting integer is of any value is another question though.
use i to extract f's sign, exponent & significand
This however, is not guaranteed by the standard as the value of a float is implementation-defined (in the case of IEEE 754 it will work though).