[Mono-dev] Patch for IntPtr bug
robertj at gmx.net
Wed Feb 11 10:24:12 EST 2009
russell.kay at realtimeworlds.com wrote:
> I encountered a problem when casting a long to an IntPtr, which is
> something we have ended up doing a lot (we want to keep binary assembly
> compatibility between x86 and x64, only changing the native code on the
> different architectures). We encountered a problem with Mono as there
> has been a check introduced into the IntPtr constructor from a long,
> this is checking the range of the long to ensure it is in range,
> unfortunately the check is incorrect. A long can easily hold from
> Int32.MinValue to UInt32.MaxValue (and not Int32.MaxValue as it
> currently in there).
The patch is wrong, since casting a long > Int32.MaxValue to a
4 byte signed intptr is simply invalid.
The current check in IntPtr.cs also matches MS.NET.
More information about the Mono-devel-list