Don't invoke undefined behaviour when doing type punning.
It is undefined behavior to read a union member with a different type from the one with which it was most recently written. (Even if GCC allows it as non-standard language extension.)
We should not invoke undefined behaviour.
Why should we not invoke undefined behaviour?
A well established result in compiler research is that invoking undefined behaviour means that we allow the compiler to make daemons fly out of our noses.
The causal link between invoking UB and the severe nose problem is called the "nasal daemon" effect in the literature.
Recent studies have shown that invoking undefined behaviour in cryptocurrency projects cause a certain subset of said nasal daemons to emerge: the privkey eating nasal deamons.
The privkey eating nasal deamons are special in that they scan your memory for private keys prior to the nose exit. Once they are outside of your nose they upload these keys to a remote server located in a foreign country (foreign in relation to the nose bearer).
That – ladies and gentlemen – is why we should not invoke undefined behaviour.