[Mono-bugs] [Bug 48393][Nor] New - Control flow analysis through gotos wrongly detect unassigned variables

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Tue, 13 Jan 2004 15:16:41 -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 martin@ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=48393

--- shadow/48393	2004-01-13 15:16:41.000000000 -0500
+++ shadow/48393.tmp.5791	2004-01-13 15:16:41.000000000 -0500
@@ -0,0 +1,68 @@
+Bug#: 48393
+Product: Mono/Compilers
+Version: unspecified
+OS: Mandrake 9.1
+OS Details: Mandrake cooker
+Status: NEW   
+Resolution: 
+Severity: Unknown
+Priority: Normal
+Component: C#
+AssignedTo: martin@ximian.com                            
+ReportedBy: alan.schmitt@polytechnique.org               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Control flow analysis through gotos wrongly detect unassigned variables
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+The control flow analysis does not seem to detect unassigned variables
+correctly when using goto.
+
+Steps to reproduce the problem:
+1. Enter the following code:
+
+class Test {
+
+  public static void Main () {
+    int x;
+
+L1:
+    switch (0) {
+      case 1:
+        goto Ln;
+      case 0:
+        x = 2;
+        goto L2;
+    }
+
+L2:
+    x = x + 1;
+    System.Console.WriteLine(x);
+
+Ln:
+    return;
+  }
+}
+
+2. Compile it
+
+Actual Results:
+
+schmitta@alan-schm1p:~/tmp> mcs bug.cs 
+bug.cs(17) error CS0165: Use of unassigned local variable `x'
+Compilation failed: 1 error(s), 0 warnings
+
+Expected Results:
+Compilation succeeds.
+
+How often does this happen? 
+All the time.
+
+Additional Information:
+mcs from mono-0.26-1mdk
+
+The same code compiles (with warnings) using csc and cscc (pnet).