[Mono-bugs] [Bug 52578][Wis] New - MCS invalidly emits a Box when converting a System.Enum to an interface

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sat, 3 Jan 2004 12:51:38 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by bmaurer@users.sf.net.

http://bugzilla.ximian.com/show_bug.cgi?id=52578

--- shadow/52578	2004-01-03 12:51:38.000000000 -0500
+++ shadow/52578.tmp.16806	2004-01-03 12:51:38.000000000 -0500
@@ -0,0 +1,54 @@
+Bug#: 52578
+Product: Mono/Compilers
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: C#
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: bmaurer@users.sf.net               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: MCS invalidly emits a Box when converting a System.Enum to an interface
+
+Description of Problem:
+
+using System;
+
+enum Foo { Bar }
+class T {
+	public static int Main ()
+	{
+		Enum e = Foo.Bar;
+		IConvertible convertible = (IConvertible) e;
+		
+		Console.WriteLine ("PASS");
+		return 0;
+	}
+}
+
+If you run the following code on Mono, you will get an invalid code error
+and mono will abort.
+
+The code that is emitted is:
+        IL_0000:  ldc.i4.0
+        IL_0001:  box Foo
+        IL_0006:  stloc.0
+        IL_0007:  ldloc.0
+        IL_0008:  box [mscorlib]System.Enum
+        IL_000d:  stloc.1
+        IL_000e:  ldstr "PASS"
+        IL_0013:  call void class
+[mscorlib]'System.Console'::'WriteLine'(string)
+        IL_0018:  ldc.i4.0
+        IL_0019:  ret
+
+IL_0008 is invalid. At this point there is an Object on the stack, it
+cannot be boxed agian.
+
+See also: bug 52569