Opened 12 years ago

Closed 12 years ago

#830 closed defect (fixed)

Disposable::GetHashCode() throws overflow exception on x64

Reported by: gregboone Owned by: gregboone
Priority: major Milestone: 3.7.0
Component: FDO API Version: 3.7.0
Severity: 2 Keywords: GetHashCode
Cc: External ID:

Description (last modified by gregboone)

Calling the managed interface function "Disposable::GetHashCode()" can result in an overflow exception if the internal pointer is larger than Int32.

svn diff Disposable.cpp

 System::Int32 NAMESPACE_OSGEO_RUNTIME::Disposable::GetHashCode()
 {
-       return m_imp.ToInt32();
+    // Solution for overflow issue taken from:
+    // http://msdn.microsoft.com/en-us/library/system.object.gethashcode(v=vs.71).aspx
+    //
+    System::Int64 i64 = m_imp.ToInt64();
+    return ((System::Int32)(i64) ^ (System::Int32)(i64 >> 32));
 }

Change History (3)

comment:1 by gregboone, 12 years ago

Description: modified (diff)

comment:2 by gregboone, 12 years ago

Summary: Disposable::GetHashCode() throws overflow exception on Int64Disposable::GetHashCode() throws overflow exception on x64

comment:3 by gregboone, 12 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.