|
|
|
|
|
by JonChesterfield
1164 days ago
|
|
I chased that rabbit hole briefly and it's not very clear that the hashed value is required to be <= UINT32_MAX. Closest is a claim by the same author as this post: > It seems obvious that on 32-bit and 64-bit systems, the function should not give different results and a commit to mask off the low bits in an implementation elsewhere. Well, maybe that would be convenient, but overall it seems unimportant. It's necessary for the tool writing the table and the tool reading it to agree but cross compilation is absolutely full of hazards like this anyway. The code looks fine to me for what that's worth. I can see the assignment in the if being contentious. |
|
No sensible engineer would design a hash function that populates the lower 28 bits of the hash code, ALWAYS leaves bits 28 through 31 clear, and then SOMETIMES sets bit 32, but only rarely and only on certain architectures.
It makes no sense as a conscious design. The logical conclusion is that the intent was to create a 28-bit hash function, and the fact that the provided code sometimes sets bit 32 is clearly a bug.