Hacker News new | ask | show | jobs
by rcfox 4502 days ago
I wish the myriad articles about this interesting hack would bother to mention that it relies on undefined behaviour. Any time you find yourself doing this:

    *(foo*)
you're probably breaking the strict aliasing rule.
1 comments

The behavior is defined, if you disable the rule or your compiler doesn't follow it.
That's the opposite of "defined", in the context of a language discussion.
It is a good thing that actual results rely on the compiler implementation, not the language.
Sure, your code will work today, with your compiler. But will it work tomorrow? Or what if your client wants to compile it on their machine, in a different operating system, with a compiler that you've never tried?
Readme, documentation, makefile(??)