[Mono-dev] Patch for IntPtr bug

Rodrigo Kumpera kumpera at gmail.com
Wed Feb 11 12:00:42 EST 2009


Russel,

I think the issue is that you're using long to represent pointers when you
should be using IntPtr only.

2009/2/11 <russell.kay at realtimeworlds.com>

>  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.
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20090211/c4d4e78e/attachment.html 


More information about the Mono-devel-list mailing list