News for hackers. Stuff that matters.
Re:You Can't Always Hash Pointers in C by tehrei on Tuesday May 31, 2016 @10:48AM (#11806802)
Oh, so then on C++ you can check if pointer-to-T p is within T a[sz]; by doing (a == p || std::less(a, p)) && (std::less(p, a + sz))
Re:You Can't Always Hash Pointers in C by gpderetta on Tuesday May 31, 2016 @04:50PM (#11810104)
Possibly not. The standard guarantees that less yields a total order for pointers. But the ordering itself is unspecified, and not even guaranteed to be consistent with operator< for pointers to elements of the same array.
Re:You Can't Always Hash Pointers in C by yoklov on Wednesday June 01, 2016 @11:39AM (#11815263)
I thought it was UB to use < on pointers outside of the same block of memory. e.g. your function is fine if the answer is true, but UB if the answer is false.

I could be misremembering though, but I do know I'd always cast to uintptr_t for this.