[Mono-bugs] [Bug 41787][Nor] New - Definite assignment errors
bugzilla-daemon@rocky.ximian.com
bugzilla-daemon@rocky.ximian.com
Wed, 23 Apr 2003 10:44:08 -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 staerk@inf.ethz.ch.
http://bugzilla.ximian.com/show_bug.cgi?id=41787
--- shadow/41787 Wed Apr 23 10:44:08 2003
+++ shadow/41787.tmp.30757 Wed Apr 23 10:44:08 2003
@@ -0,0 +1,136 @@
+Bug#: 41787
+Product: Mono/MCS
+Version: unspecified
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: Misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: staerk@inf.ethz.ch
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Definite assignment errors
+
+Here are some programs where Mono's MCS and Microsoft's CSC do
+not agree on definite assignement (see also 13.3.3 "Precise rules
+for determining definite assignment" in the Ecma C# standard).
+------------------------------------------------------------------------
+using System;
+
+class Test14 {
+ static void F(bool b, int i) {
+ int x;
+ if (b && (x = i) >= 0)
+ // OK: 'x' definitely assigned
+ Console.WriteLine(x);
+ else
+ // Error: 'x' not definitely assigned
+ Console.WriteLine(x);
+ }
+
+ public static void Main() {
+ F(true,5);
+ F(false,7);
+ }
+}
+
+// Mono (mcs 0.23 Redhat 7.2)
+// > mcs Test14.cs
+// Compilation succeeded
+// qed> mono Test14.exe
+// 5
+// 0
+
+// Microsoft .NET
+// > csc Test14.cs
+// Test14.cs(11,25): error CS0165: Use of unassigned local variable 'x'
+------------------------------------------------------------------------
+using System;
+
+class Test15 {
+ static void F(bool b, int i) {
+ int x;
+ if (b || (x = i) >= 0)
+ // Error: 'x' not definitely assigned
+ Console.WriteLine(x);
+ else
+ // OK: 'x' definitely assigned
+ Console.WriteLine(x);
+ }
+
+ public static void Main() {
+ F(true,5);
+ F(false,7);
+ }
+}
+
+// Mono (mcs 0.23 Redhat 7.2)
+// > mcs Test15.cs
+// Compilation succeeded
+// qed> mono Test15.exe
+// 0
+// 7
+
+// Microsoft .NET
+// > csc Test14.cs
+// Test14.cs(11,25): error CS0165: Use of unassigned local variable 'x'
+------------------------------------------------------------------------
+using System;
+
+class Test13 {
+ static void F(int i) {
+ int x;
+ while (true) {
+ if (i < 7) {
+ x = 3;
+ break;
+ }
+ }
+ // OK: 'x' definitely assigned
+ Console.WriteLine(x);
+ }
+
+ public static void Main() {
+ F(4);
+ }
+}
+
+// Mono (mcs 0.23 Redhat 7.2)
+// > mcs Test13.cs
+// Test13.cs(13) error CS0165: Use of unassigned local variable `x'
+// Compilation failed: 1 error(s), 0 warnings
+
+// Microsoft .NET
+// > csc Test13.cs
+// > Test13.exe
+// 3
+------------------------------------------------------------------------
+using System;
+
+class Test5 {
+ static void F(bool b) {
+ int x;
+ while (b?true:true);
+ // OK: 'x' definitely assigned
+ Console.WriteLine(x);
+ }
+
+ public static void Main() {
+ F(true);
+ }
+}
+
+// Mono (mcs 0.23 Redhat 7.2)
+// > mcs Test5.cs
+// Test5.cs(8) error CS0165: Use of unassigned local variable `x'
+// Compilation failed: 1 error(s), 0 warnings
+
+// Microsoft .NET
+// > csc Test5.cs
+// > Test5.exe
+------------------------------------------------------------------------