[Mono-dev] Patch for IntPtr bug
russell.kay at realtimeworlds.com
russell.kay at realtimeworlds.com
Wed Feb 11 09:56:37 EST 2009
All,
Not sure the best way to submit this, please correct me if there is a
better way to do this (via bugzilla?)
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).
See attached patch (contributed under the MIT X11 license) to introduce
the one extra character that makes the range check correct.
Can I also say that I think the check should really be in a Debug.Assert
so that it disappears in non-Debug versions, the check is good for
sanity checking but superfluous on released code.
Regards
Russell
____________________________________________________________________
DISCLAIMER
This message and any attachments contain privileged and confidential information intended for the use of the addressee named above. If you are not the intended recipient of this message, you are hereby notified that any use, dissemination, distribution or reproduction of this message is prohibited. Please note that we cannot guarantee that this message or any attachment is virus free or that it has not been intercepted and amended. The views of the author may not necessarily reflect those of Realtime Worlds Ltd.
Realtime Worlds Ltd is registered in Scotland, number 225628. Registered Office: 152 West Marketgait, Dundee, DD1 1NJ.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20090211/e03941e4/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: IntPtr.diff
Type: application/octet-stream
Size: 539 bytes
Desc: IntPtr.diff
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20090211/e03941e4/attachment-0001.obj
More information about the Mono-devel-list
mailing list