>> Note that this implementation has undefined behavior according to the standard because union members are accessed that haven't been written to.
Except when the union member you are reading is a 'common initial sequence' [1] of the union member that was written, to be precise ;-). But that's not the case here.
Except when the union member you are reading is a 'common initial sequence' [1] of the union member that was written, to be precise ;-). But that's not the case here.
[1] https://stackoverflow.com/q/34616086/2757035