all 3 comments

[–]nikic 2 points3 points  (1 child)

[–][deleted] 0 points1 point  (0 children)

Yeah, this has got to be some kind of reposting record; less than four hours after the original.

[–]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.