[Mono-list] Bug in mcs: casting type enum to integral type

Paolo Molaro lupus@ximian.com
Tue, 26 Feb 2002 15:02:02 +0100


On 02/26/02 Miguel de Icaza wrote:
> Hello Adam!
> 
> > Noticed another bug in the compiler.  mcs is having trouble compiling classes 
> > with explicit casting of type enum to one of the integral types.  The 
> > following test outlines the error.  The error I recieve is:
> > 
> > Unhandled exception System.NullReferenceException A null value was found 
> > where an object instance was required.
> > #0: 0x00001 callvirt   in Mono.CSharp.Expression::ConvertNumericExplicit 
> > ([0x81d0a58] [(nil)] [0x80ecd38] )
> > #1: 0x0007e call       in Mono.CSharp.Expression::ConvertExplicit 
> > ([0x81d0a58] [0x81e1cf0] [0x80ecd38] [vt: 0xbfffddec] )
> 
> That looks like a bug in our classes, because the compiler on Windows
> can cope with that.

Yes, probably some convert stuff missing.
But there is also a bug in the compiler. ecore.cs, about line 1800:

		e = ConvertImplicit (ec, e, target_type, loc);
		if (e != null)
			return e;
				
		return ConvertNumericExplicit (ec, e, target_type);

If ConvertImplicit() returns null, e is passed to ConvertNumericExplicit(),
but that method expects e to be non-null.

> The way we parse hex strings in the compiler is by calling this:
> 
> 	ul = System.UInt64.Parse (s,NumberStyles.HexNumber);
> 
> My guess is that we have yet to implement Parse correctly in most of our
> Int classes.  We have a small fast implementation for the common code
> path, but we do not support the complete Parse specification.  

I think this explains the other bug Adam reported. I fixed that,
at least for UInt64.

lupus

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