[Mono-bugs] [Bug 52427][Wis] New - invalid IL from do { if (a) break; throw new Exception } while true

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sun, 21 Dec 2003 15:40:47 -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=52427

--- shadow/52427	2003-12-21 15:40:47.000000000 -0500
+++ shadow/52427.tmp.1120	2003-12-21 15:40:47.000000000 -0500
@@ -0,0 +1,48 @@
+Bug#: 52427
+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: invalid IL from do { if (a) break; throw new Exception } while true
+
+using System;
+
+class T {
+	static bool a;
+	static void Main () {
+		do {
+			if (a)
+				break;
+			throw new NotImplementedException ();
+		} while (true);
+	}
+}
+
+Run and you get 
+** ERROR **: Invalid IL code at IL000a in .T:Main (): IL_000a: br       
+IL_001a
+
+the IL code is: 
+
+        IL_0000:  ldsfld  bool 'T'::'a'
+        IL_0005:  brfalse IL_000f
+ 
+        IL_000a:  br IL_001a
+ 
+        IL_000f:  newobj instance void class
+[mscorlib]'System.NotImplementedException'::.ctor()
+        IL_0014:  throw
+        IL_0015:  br IL_0000
+
+Note the branch goes outside the method.