Re:You Can't Always Hash Pointers in C (2016)
by saagarjha on Wednesday September 19, 2018 @03:11AM
(#18022362)
I really don't care what the actual value of the pointers are, since I'm not going to use them for anything other than key lookup. The thing that breaks in your case is hash table iteration, but if I'm not doing that I still don't see any non-reproducible behavior other than slight timing differences.
Re:You Can't Always Hash Pointers in C (2016)
by Zanni on Wednesday September 19, 2018 @05:11AM
(#18022902)
If you read the article, there's an explicit mention of the possibility of tagged pointers for some implementations, where the low-order bits represent the address and the high-order bits are used for housekeeping and might change dynamically. Thus the pointer to the same object might naively cast to different integers at different times in program execution. That will lead to non-reproducible behavior.
Re:You Can't Always Hash Pointers in C (2016)
by wruza on Wednesday September 19, 2018 @08:34AM
(#18023703)
Given the factual amount of times it will happen, even this small thread is not worth it except for few pedants. And on architectures where it will, and on compilers that dare to make it happen — it will break much more than just your clever code anyway. All these ancient standard details are there only for history. In reality, you cannot even change the direction of memcpy(3) without turning the world upside down.
Re:You Can't Always Hash Pointers in C (2016)
by rurban on Wednesday September 19, 2018 @06:56PM
(#18028306)
sure, but in practice everybody knows the actually used bits of every pointers per platform. on amd64 e.g. it's the 2 lowest and 16 highest which need to be masked off for comparison. it's simply platform and vm dependent.
I know very well where and how I'm able to compare ptrs in a hash table, and I'm doing it all the time. just complaining out loud is no solution.
No that's false. See my clarification above.