I figured that you might tell the page or give an explanation. I cannot find any conherence to this case and being undefined. The standard doesn't say anything about undefined usage of an union with non-static data members. It says the size will depend on the largest member and in our case that depends on the machine. That means the union is declared, defined but not yet initialized. But a non-static data member of a union may have an equal-initializer. Thats what we have here. So everything is just fine but you need to take care of what happens.
In a union, at most one of the non-static data members can be active at any time, that is, the value of at
most one of the non-static data members can be stored in a union at any time. [ Note: One special guarantee
is made in order to simplify the use of unions: If a standard-layout union contains several standard-layout
structs that share a common initial sequence (9.2), and if an object of this standard-layout union type
contains one of the standard-layout structs, it is permitted to inspect the common initial sequence of any of
standard-layout struct members; see 9.2. —end note ] The size of a union is sufficient to contain the largest
of its non-static data members. Each non-static data member is allocated as if it were the sole member of a
struct
Note, specifically: The value of at most one of the non-static members may be active at any one time.
the active member is myfloat.a on line 9 when you write to it.
On line 11 you venture into undefined territory by accessing the inactive member, b. Does it do something sensible? One would have to question the QOI of compilers that didn't. Is it undefined behavior? Yes.
used doesn't have anything to do with which member is active, unless, as you say the programmer uses it to keep track of which is active. Changing it, however, doesn't change which member is active.