[Mono-bugs] [Bug 52597][Wis] New - We generate invalid code for using idisposable structs

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sun, 4 Jan 2004 23:45:46 -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=52597

--- shadow/52597	2004-01-04 23:45:46.000000000 -0500
+++ shadow/52597.tmp.31946	2004-01-04 23:45:46.000000000 -0500
@@ -0,0 +1,53 @@
+Bug#: 52597
+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: We generate invalid code for using idisposable structs
+
+using System;
+
+struct Blah : System.IDisposable {
+	public void Dispose () {
+		Console.WriteLine ("foo");
+	}
+}
+
+class B  {
+	static void Main () {
+		using (Blah b = new Blah ()) {
+			Console.WriteLine ("...");
+		}
+	}
+}
+
+When compiled and run on Mono we get,
+
+** ERROR **: Invalid IL code at IL001d in .B:Main (): IL_001d: ldloc.0
+
+The IL in question is:
+
+          IL_0017:  ldloc.0
+          IL_0018:  brfalse IL_0023
+ 
+          IL_001d:  ldloc.0
+          IL_001e:  callvirt instance void class
+[mscorlib]'System.IDisposable'::'Dispose'()
+          IL_0023:  endfinally
+
+MS generates:
+
+      IL_0014:  ldloca.s   V_0
+      IL_0016:  call       instance void Blah::Dispose()
+      IL_001b:  endfinally