[Mono-bugs] [Bug 70419][Wis] New - the last branch of "for" statement is incorrectly skipped
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Fri, 10 Dec 2004 06:23:51 -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 atsushi@ximian.com.
http://bugzilla.ximian.com/show_bug.cgi?id=70419
--- shadow/70419 2004-12-10 06:23:51.000000000 -0500
+++ shadow/70419.tmp.550 2004-12-10 06:23:51.000000000 -0500
@@ -0,0 +1,63 @@
+Bug#: 70419
+Product: Mono: Compilers
+Version: 1.1
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Wishlist
+Component: C#
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: atsushi@ximian.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: the last branch of "for" statement is incorrectly skipped
+
+This looks like a bug in computation of unreachable block in "for"
+statement. The example below results different when compiled with csc and
+when compied with mcs:
+
+--------
+using System;
+
+public class Test
+{
+ static int flag = 0;
+ static int iter = 1;
+
+ public static void Main ()
+ {
+ for (int x = 0; x <= iter; x++, iter--) {
+ if (flag == 0)
+ continue; // iter
+ else
+ break;
+ }
+ Console.WriteLine (iter);
+ }
+}
+
+Steps to reproduce the problem:
+1. compile with mcs and run
+2. compile with csc and run (don't worry; I put the result below)
+
+
+Actual Results:
+$ mcs forloop.cs
+forloop.cs(10) warning CS0162: Unreachable code detected
+ - 1 warning(s)
+
+$ mono forloop.exe
+1
+
+Expected Results:
+$ csc /nologo forloop.cs
+
+$ mono forloop.exe
+0
+
+How often does this happen?
+- Consistently.