But not so legal in C89. Unfortunately a lot of supposedly secure code is written, using this older standard. Furthermore, make some tiny mistake and suddenly you introduce forbidden pointer aliasing, look at answers 2 here http://stackoverflow.com/questions/2566 ... pe-punningsyzygy wrote:...
Hmm, it is certainly perfectly legal in C99 and C11.
And what about Visual Studio, Comeau and Intel? This really gets complicated.syzygy wrote: ...
In C++ it might be formally undefined, but at least g++ allows it as a language-extension. I'm sure Clang then does the same.
Problems over problems for no good reason. Why not just use clean and simple shift instructions and you are done?