[Mono-bugs] [Bug 70400][Min] New - Wrong behavior of breaking out of SWITCH, when done from within a nested SWITCH and a nested IF
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Thu, 9 Dec 2004 17:42:10 -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 vgapeyev@cis.upenn.edu.
http://bugzilla.ximian.com/show_bug.cgi?id=70400
--- shadow/70400 2004-12-09 17:42:10.000000000 -0500
+++ shadow/70400.tmp.26519 2004-12-09 17:42:10.000000000 -0500
@@ -0,0 +1,90 @@
+Bug#: 70400
+Product: Mono: Compilers
+Version: 1.0
+OS:
+OS Details: Mandrake 10.0
+Status: NEW
+Resolution:
+Severity:
+Priority: Minor
+Component: C#
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: vgapeyev@cis.upenn.edu
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Wrong behavior of breaking out of SWITCH, when done from within a nested SWITCH and a nested IF
+
+Description of Problem:
+
+Suppose there is a SWITCH, with a nested SWITCH, with a nested IF. If
+there is a BREAK inside IF, it should switch the control into the
+inner SWITCH, but it jumps into the outer SWITCH.
+
+To reproduce the bug, the condition in the IF must be computable,
+(rather than a constant which probably gets optimized away).
+
+
+Steps to reproduce the problem:
+Compile and run this (mono 1.0.5):
+
+using C = System.Console;
+
+class Test {
+
+ public static void Main (string[] args) {
+ switch (1) {
+ default:
+ switch (2) {
+ default:
+ int flag = 1; //makes the next if computable -- essential!
+ if (flag == 1) {
+ C.WriteLine("**** This one is expected");
+ break; //break-2
+ }
+ else goto lbl;
+ }
+ break; //break-1 This point is REACHABLE through break-2,
+ // contrary to the warning from compiler!
+
+ lbl:
+ C.WriteLine("**** THIS SHOULD NOT APPEAR, since break-1 was
+supposed to fire ***");
+ break;
+
+ }
+ }
+}
+
+
+
+Actual Results:
+
+% mcs simple.cs
+simple.cs(17) warning CS0162: Unreachable code detected
+Compilation succeeded - 1 warning(s)
+% mono simple.exe
+**** This one is expected
+**** THIS SHOULD NOT APPEAR, since break-1 was supposed to fire ***
+
+
+Expected Results:
+
+The last line of the output should not appear.
+
+The compiler warning should not appear, since the corresponding point
+IS reachable, as explained in the Description above.
+
+
+How often does this happen?
+
+Completely reproducible.
+
+
+Additional Information:
+
+This bug is probably the same as #59867. I have just noticed that the
+latter was marked as RESOLVED FIXED, so I re-raise it here. The code
+reported in #5986 still fails to work correctly with mono/mcs 1.0.5,
+but the sample above is a little shorter.