[Mono-bugs] [Bug 48207][Nor] New - CS0163 triggered by dead code elimination
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Sun, 7 Sep 2003 15:57:48 -0400 (EDT)
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 schuller+ximian@lunatech.com.
http://bugzilla.ximian.com/show_bug.cgi?id=48207
--- shadow/48207 2003-09-07 15:57:48.000000000 -0400
+++ shadow/48207.tmp.15914 2003-09-07 15:57:48.000000000 -0400
@@ -0,0 +1,57 @@
+Bug#: 48207
+Product: Mono/MCS
+Version: unspecified
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: Misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: schuller+ximian@lunatech.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: CS0163 triggered by dead code elimination
+
+Mono C# compiler version 0.26.0.0
+
+In a switch statement, if a case ends in an endless loop (which
+conditionally does a return or a throw), then no matter what I do, I always
+get error CS0163: Control cannot fall through from one case label to another.
+Attempts to end the case with a break; are greeted with warning CS0162:
+Unreachable code detected.
+
+Example code:
+
+// I can't win:
+// case-bug.cs(23) warning CS0162: Unreachable code detected
+// case-bug.cs(18) error CS0163: Control cannot fall through from one case
+// label to another
+public class Foo
+{
+ public static void Main()
+ {
+ int a=5;
+ int b=10;
+ int c;
+
+ switch (a)
+ {
+ case 1: c=a+b;
+ return;
+
+ case 2: c=a-b;
+ while(true) {
+ if (c == 3)
+ return;
+ }
+ break;
+
+ case 3: c=a*b;
+ break;
+ }
+ }
+}