[Mono-devel-list] Prevalence of pointer-integral-pointer casting in mono?

Paolo Molaro lupus at ximian.com
Mon Aug 2 04:53:33 EDT 2004

On 08/01/04 Jonathan Pryor wrote:
> On Sun, 2004-08-01 at 20:44, Peter Colson wrote:
> > A general code question. Does the mono runtime make extensive use of the
> > casting of pointers to integral types and then casting back to a
> > pointer, expecting the pointer to be useable?
> I'm not sure about Mono, but glib (one of Mono's dependencies) does
> this.  It is generally assumed that a gint can be held in a gpointer.

Yes, but this is the opposite problem:
*) you can store an int in a pointer and get back the int if you use the
glib macros
*) you can't store a pointer in an int and get back the pointer

Now, since mono had a couple of 64 bit ports, there should not be issues
like that in the code (don't remember if we ever had bugs like that,
I'm sure that in some places a long or unsigned long is used to hold a
possible pointer value: this is a problem, but only on broken platforms
that defined a long to be 32 bits even on 64 bits platforms (you guessed
it right, apparently windows on 64 bit cpus is the only 'modern' OS to
inflict that model on developers). So, there is no hurry to fix this
(and the general mono code shouldn't have that pattern, it's just in
some jit code so probably just the amd64 support needs to be audited).
On all the Linux-based platforms assuming a long contains a pointer is


lupus at debian.org                                     debian/rules
lupus at ximian.com                             Monkeys do it better

More information about the Mono-devel-list mailing list