The C99 specification states this:
When a value is stored in a member of an object of union type, the bytes of the object representation that do not correspond to that member but do correspond to other members take unspecified values.
Here, you write one value using one object of a union type and after you try to access the other object of this union type. This leads to unpredictable value in your type.
Thus, you can't do something like this. You should only use one object of the union for a same instance of a struct.