--On Tuesday, November 23, 2010 04:53:38 PM +0100 Alan DeKok <aland@deployingradius.com> wrote:
Jeffrey Hutzelman wrote:
You should be -- if the compiler accepts it at all, it changes the semantics. Casting void * to int is not strictly legal and won't work on platforms where void * is larger than int. That said, the existing code is not that great, either -- ptrdiff_t is not guaranteed to fit in an int; in fact, I just found a bug last night in another piece of software caused by ptrdiff_t being long.
Hmmm... ugh.
My thoughts exactly.
Of course, the OP hasn't reported what the original error was, so I can't really suggest a better fix, but I'll bet it involves changing the return type of eap_handler_ptr_cmp().
Or:
if (a < b) return -1; if (a > b) return +1; return 0;
The values don't matter, only the sign, and the fact that the calculation is transitive across more than 2 pointers.
Oh; this is a comparator for a btree. Yeah, this seems like the sanest thing to do. -- Jeff