2 ms·
Googling I've found for example this: “GNU extensions to standard C++ (and to C90) do explicitly allow type-punning with unions. Other compilers that don't sup
by acqq 8y ago
Googling I've found for example this:
“GNU extensions to standard C++ (and to C90) do explicitly allow type-punning with unions. Other compilers that don't support GNU extensions may also support union type-punning, but it's not part of the base language standard.”
Also, apparently in C99 one relevant statement was:
“The value of a union member other than the last one stored into [is unspecified]”
https://stackoverflow.com/questions/25664848/unions-and-type-punning https://stackoverflow.com/questions/25664848/unions-and-type...
Note: In case it's not obvious, I, personally, believe that, at least, using unions for type-punning has to exist and should be explicitly supported in the standards too. And that the compiler contributors should not produce practically unusable results even when some standard is wrong (for common use) or unclear. But the quotes like the above give a hint on which basis some try to cling to bad approaches in this special case. In other cases it's probably even harder to avoid unwanted results.