News for hackers. Stuff that matters.
Re:Everything in C is undefined behavior by stevenhuang on Wednesday May 20, 2026 @06:06PM (#48214881)
Yes, I sympathize with you that it's tricky enough. I didn't find the first example with foo() as the author trying deliberately to be tricksy (ie saying the snippet itself is UB by construction), but I certainly see how it can be read that way. It again lends to how hard all of this is to explain!

One thing though, for parse() not only is it violating strict aliasing, it is also indeed violating alignment requirements.

To quote the standard again:

> 6.3.2.3. 755 If the resulting pointer is not correctly aligned for the pointed-to type, the behavior is undefined.

There are no comments on this comment yet.