Closed Bug 885175 Opened 7 years ago Closed 7 years ago
Fix hashing of doubles
DefaultHasher<double>'s hash method uses a union which causes it to return values which depend on the endianness, and its match method uses floating-point equality, so it doesn't handle negative zeros or NaNs properly.
Could you use BitwiseCast<uint64_t> instead (see use in ion/MIR.cpp)?
Does the existing DefaultHasher stuff use mfbt/HashFunctions.h at all? Would probably be good to add some double overloads and functions there, and use that. (The existing code there looks like it'd hash the double as if it were a uint32_t, which is wrong in all sorts of ways.)
Luke: Updated patch using BitwiseCast<uint64_t>. It's nicer :-). Jeff: As far as I can tell, nothing in js/public/HashTable.h uses mfbt/HashFunctions.h currently. Switching it over looks like a bigger project than I'm interested in tackling at this time.
Comment on attachment 765482 [details] [diff] [review] an updated patch, following review feedback Great! Feel free to take over bug 876064, btw.
Attachment #765482 - Flags: review?(luke) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/806a358aa8b2 Also, yes, I do plan to take over bug 876064 soon :).
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla24
You need to log in before you can comment on or make changes to this bug.