News for hackers. Stuff that matters.
Re:With Undefined Behavior, Anything Is Possible by comex on Saturday August 18, 2018 @12:25AM (#17786861)
From a standards perspective that’s pretty much right AFAIK. From a practical perspective, it’s also explicitly endorsed in the GCC manual, so I don’t think there’s much risk of popular compilers breaking it in the foreseeable future:

> The practice of reading from a different union member than the one most recently written to (called “type-punning”) is common. Even with -fstrict-aliasing, type-punning is allowed, provided the memory is accessed through the union type. So, the code above works as expected.

https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

There are no comments on this comment yet.