summaryrefslogtreecommitdiff
path: root/cpp/src/slice2objc
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2017-01-26 17:17:36 -0500
committerBernard Normier <bernard@zeroc.com>2017-01-26 17:17:36 -0500
commitcb899451044f7559c4f018ee8f4898375876fb05 (patch)
treede537c7b3a6465330d5c7695c186bc19038b9561 /cpp/src/slice2objc
parentPython: Ice.Value implementation (diff)
downloadice-cb899451044f7559c4f018ee8f4898375876fb05.tar.bz2
ice-cb899451044f7559c4f018ee8f4898375876fb05.tar.xz
ice-cb899451044f7559c4f018ee8f4898375876fb05.zip
Fixed bug in float hash function
Diffstat (limited to 'cpp/src/slice2objc')
-rw-r--r--cpp/src/slice2objc/Gen.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/cpp/src/slice2objc/Gen.cpp b/cpp/src/slice2objc/Gen.cpp
index e3b471d11f4..8b927cc9830 100644
--- a/cpp/src/slice2objc/Gen.cpp
+++ b/cpp/src/slice2objc/Gen.cpp
@@ -2040,13 +2040,16 @@ Slice::Gen::TypesVisitor::writeMemberHashCode(const DataMemberList& dataMembers,
}
case Builtin::KindFloat:
{
- _M << nl << "h_ = ((h_ << 5) + h_) ^ (2654435761u * (uint)" << name << ");";
+ _M << sb;
+ _M << nl << "uint32_t bits_ = *(uint32_t*)&" << name << ";";
+ _M << nl << "h_ = ((h_ << 5) + h_) ^ (uint)bits_;";
+ _M << eb;
break;
}
case Builtin::KindDouble:
{
_M << sb;
- _M << nl << "unsigned long long bits_ = *(unsigned long long*)&" << name << ";";
+ _M << nl << "uint64_t bits_ = *(uint64_t*)&" << name << ";";
_M << nl << "h_ = ((h_ << 5) + h_) ^ (uint)(bits_ ^ (bits_ >> 32));";
_M << eb;
break;