[Mono-bugs] [Bug 70185][Min] New - CS0165: local variable assignation placed after goto statement are incorrectly regarded as valid
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Fri, 3 Dec 2004 09:31:06 -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=70185
--- shadow/70185 2004-12-03 09:31:06.000000000 -0500
+++ shadow/70185.tmp.15256 2004-12-03 09:31:06.000000000 -0500
@@ -0,0 +1,47 @@
+Bug#: 70185
+Product: Mono: Compilers
+Version: 1.1
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Minor
+Component: C#
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: atsushi@ximian.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: CS0165: local variable assignation placed after goto statement are incorrectly regarded as valid
+
+When we have goto statement inside a block and there is a local variable
+assignation after that goto, it must not be regarded as "already assigned"
+(since skipped execution might reference it). csc checkes it, but mcs does not.
+
+
+using System;
+
+public class Test
+{
+ public int i;
+
+ public void Hoge ()
+ {
+ if (i > 0)
+ goto Fuga;
+ string s = "defined later";
+ Fuga:
+ Console.WriteLine (s);
+ }
+}
+
+Actual Results:
+compiled without CS0165 error.
+
+Expected Results:
+cs0165-goto.cs(13,22): error CS0165: Use of unassigned local variable 's'
+
+How often does this happen?
+consistently.