News for hackers. Stuff that matters.
Re:A bug story: data alignment on x86 by tropo on Monday November 07, 2016 @12:07PM (#12892647)
You also need the may_alias attribute to prevent other problems.

Data written as int may be read as char, but going the other way is usually a standards violation. (an exception being if you had used char to implement a memcpy-like function, but in that case you should expect compiler bugs to bite you)

Re:A bug story: data alignment on x86 by Thiez on Monday November 07, 2016 @01:57PM (#12893780)
Implementing `memcpy` can be a challenge of its own. Gcc has a tendency to replace memcpy implementations with a call to... memcpy. Which is quite smart, just not in that particular context...

[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56888

Re:A bug story: data alignment on x86 by qb45 on Tuesday November 08, 2016 @12:26PM (#12902121)
Interesting, but is this a real world problem or just a standard nobody follows? I'm under impression that lots of networking and storage code running in the wild casts back and forth between char arrays and other types without giving it a thought.

And yes, as for other casts, I'm well aware that they cause problems.