[Mono-bugs] [Bug 25171] New - mcs doesn't catch usage of uninitialised variable
bugzilla-daemon@rocky.ximian.com
bugzilla-daemon@rocky.ximian.com
23 May 2002 12:00:04 -0000
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 detlev@die-offenbachs.de.
http://bugzilla.ximian.com/show_bug.cgi?id=25171
--- shadow/25171 Thu May 23 08:00:04 2002
+++ shadow/25171.tmp.13683 Thu May 23 08:00:04 2002
@@ -0,0 +1,67 @@
+Bug#: 25171
+Product: Mono/MCS
+Version: unspecified
+OS:
+OS Details: SuSE 8.0
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: Misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: detlev@die-offenbachs.de
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: mcs doesn't catch usage of uninitialised variable
+
+mcs v0.11 (CVS of May, 21st) doesn't flag the usage of an uninitialised
+variable as an error. The example was taken from "Programming C#".
+
+The code is as follows.
+---------------------------------------------
+using System;
+
+public struct Location {
+ public Location(int xCoordinate, int yCoordinate) {
+ xVal = xCoordinate;
+ yVal = yCoordinate;
+ }
+
+ public int x {
+ get {
+ return xVal;
+ }
+ set {
+ xVal = value;
+ }
+ }
+
+ public int y {
+ get {
+ return yVal;
+ }
+ set {
+ yVal = value;
+ }
+ }
+
+ public override string ToString() {
+ return (String.Format("{0}, {1}", xVal, yVal));
+ }
+
+ public int xVal;
+ public int yVal;
+}
+
+public class Tester {
+
+ static void Main() {
+ Location loc1; // no call to the constructor
+ loc1.xVal = 75; // initialize the members
+// loc1.yVal = 225;
+ Console.WriteLine(loc1); // <--- error
+ }
+}
+------------------------------------------------------------