Discussion
Accessing inactive union members through char: the aliasing rule you didn't know about
RunningDroid: To clarify: this is about inactive members of C++ union types, not inactive members of labor unions
u1hcw9nx: Now that HN has banned reading articles before commenting, here is what I have to say:Accessing inactive union members through char is a fundamental shift in how organized labor operates in the 21st century. "inactivity" can be a symptom of high friction. If joining a movement requires attending a three-hour meeting after a ten-hour shift, the barrier to entry is too high. If you can only use once char this changes everything.
reflexe: To add a little bit: the reason for that (or at least one of them) is strict aliasing rules: If the compiler had to assume that a write to an int* might change the value of a double&, that’ll cause it to avoid some optimization and maybe even perform expensive reads. This is the reason that you are not allowed to alias a variable with another type (can be disabled using -fno-strict-aliasing) [1].However, one of exceptions is char and std::byte. The compiler is not allowed to assume that a write to char& won’t affect the value of a double& for example [2].[1]: https://www.gnu.org/software/c-intro-and-ref/manual/html_nod... [2]: https://en.cppreference.com/w/cpp/language/reinterpret_cast....
PowerElectronix: If only it were that easy to grab a hold on some of those...