On Thu, 31 Jul 1997, Peter Gerwinski wrote:
According to Bill Currie:
I'VE FIXED IT!! The problem was caused by a negative index into the hash table.
Congratulations and thank you!
To fix it change the line (gci-hash.c:122):
(((((char *)(NODE))-(char *)0) >> 2) % MAX_HASH_TABLE)
to:
(((((unsigned long)(NODE))-(unsigned long)0) >> 2) % MAX_HASH_TABLE)
Since pointers and `long' integers don't have the same size on some sytems (I know it for the Alpha), I think this should be changed to something like `(unsigned size_t)'.
Peter,
In the alpha:
sizeof(long) == sizeof(void *) sizeof(int) != sizeof(void *)
Quickly thinking, in all Unix machines it might be that sizeof(long) == sizeof (void *). But this just might not always be the case, so it can not be trusted.
In ANSI C the result of (ptr - ptr) is of type ptrdiff_t, which in the alpha is (signed long).
Using cast (unsigned size_t) might not be a good idea, at least I do not know if Ansi C quarantees that size_t always is as large as ptrdiff_t.
I suggest that this problem is fixed by casting the result of the pointer subtraction to (unsigned ptrdiff_t) which is always large enough, something like:
(((unsigned ptrdiff_t)(((char *)(NODE))-(char *)0) >> 2) % MAX_HASH_TABLE)
Juki jtv@hut.fi