[Mono-list] Uninitialized variable not found by mcs

Detlev Offenbach detlev@die-offenbachs.de
Fri, 10 May 2002 12:31:58 +0200


--------------Boundary-00=_A95WMJ8FYJUSXPQGPLW8
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: 8bit

Hello,

I am starting to learn C# using mono. The attached example taken from 
"Programming C#" does not produce a compiler errormessage saying that the 
variable myInt is used uninitialized. It compiles cleanly instead (used 
mcs v0.11). Furthermore the uninitialized variable was not implicitly 
initialized to 0 (as good C and C++ compilers do). I don't know, if this 
is in error as well. The output from the run was

Uninitialized, myInt: -1073746096
After assignment, myInt: 5
-- 
Detlev Offenbach
detlev@die-offenbachs.de

--------------Boundary-00=_A95WMJ8FYJUSXPQGPLW8
Content-Type: text/plain;
  charset="us-ascii";
  name="ex3-2.cs"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="ex3-2.cs"

class Values {

    static void Main() {
        int myInt;
        System.Console.WriteLine("Uninitialized, myInt: {0}", myInt);
        myInt = 5;
        System.Console.WriteLine("After assignment, myInt: {0}", myInt);
    }
}

--------------Boundary-00=_A95WMJ8FYJUSXPQGPLW8--