[Mono-bugs] [Bug 31816][Nor] New - mcs generates bogus code on using() statements with non-IDisposable objects
bugzilla-daemon@rocky.ximian.com
bugzilla-daemon@rocky.ximian.com
6 Oct 2002 04:31:16 -0000
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 vladimir@pobox.com.
http://bugzilla.ximian.com/show_bug.cgi?id=31816
--- shadow/31816 Sun Oct 6 00:31:16 2002
+++ shadow/31816.tmp.5176 Sun Oct 6 00:31:16 2002
@@ -0,0 +1,53 @@
+Bug#: 31816
+Product: Mono/MCS
+Version: unspecified
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: Misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: vladimir@pobox.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: mcs generates bogus code on using() statements with non-IDisposable objects
+
+given:
+/** startcode **/
+using System;
+
+public class Driver {
+ public Driver () {
+ Console.WriteLine ("constructor");
+ }
+
+ public static void Main (string[] args) {
+ using (Driver d = new Driver ()) {
+ Console.WriteLine ("using");
+ }
+ }
+}
+/** endcode */
+
+mcs compiles this without error. Upon running with mint or mono, a
+NullReferenceException is generated (SEGV). monodis reveals Main to be
+generated as follows:
+
+ // method line 2
+ .method public static
+ default void Main(string[] args) cil managed
+ {
+ // Method begins at RVA 0x20fe
+ .entrypoint
+ // Code size 0 (0x0)
+ .maxstack 0
+ .locals init (
+ class Driver V_0)
+ } // end of method default void Main(string[] args)
+
+(generating a method without any instructions should probably generate at
+least some sort of exception)