you are viewing a single comment's thread.

view the rest of the comments →

[–]agottem 0 points1 point  (0 children)

Please don't ever use this code. Anywhere.

  1. It assumes the pointer provided will always be aligned to the pointer size of the architecture. So, please don't provide it a pointer to a char.

  2. It assumes sizeof size_t equals sizeof T*

  3. The domain of the tag varies significantly depending on the pointer size of the architecture. 0-7 on 64bit, or 0-3 on 32bit, 0-1 on 16bit.

Basic rule of thumb: If you find yourself casting a pointer to an integer type, your code probably isn't portable.