3 ms·
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 violat
by tropo 10y ago
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)
- Thiez 10y agoImplementing `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 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56888
- qb45 10y agoInteresting, 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.