[Mono-bugs] [Bug 72195][Nor] New - wrong error and crash when compiling unreachable code

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 3 Feb 2005 14:36:57 -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 lupus@ximian.com.


--- shadow/72195	2005-02-03 14:36:57.000000000 -0500
+++ shadow/72195.tmp.20057	2005-02-03 14:36:57.000000000 -0500
@@ -0,0 +1,51 @@
+Bug#: 72195
+Product: Mono: Compilers
+Version: 1.1
+OS Details: 
+Status: NEW   
+Priority: Normal
+Component: C#
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: lupus@ximian.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+Summary: wrong error and crash when compiling unreachable code
+The test case:
+using System;
+class T {
+	static void Main (string[] args) {
+		if (false && args.Length > 0) {
+			string s = args [0];
+			Console.WriteLine (s);
+		}
+	}
+Gives the wrong error:
+/mnt/net/cstests/uninit-var.cs(8) error CS0165: Use of unassigned local
+variable `s'
+and then makes mcs crash with the exception:
+Unhandled Exception: System.NullReferenceException: Object reference not
+set to an instance of an object
+in <0x00017> Mono.CSharp.StatementExpression:Resolve (Mono.CSharp.EmitContext)
+in <0x00191> Mono.CSharp.Block:Resolve (Mono.CSharp.EmitContext)
+in <0x0008d> Mono.CSharp.Block:ResolveUnreachable
+in <0x00166> Mono.CSharp.If:Resolve (Mono.CSharp.EmitContext)
+in <0x00191> Mono.CSharp.Block:Resolve (Mono.CSharp.EmitContext)
+in <0x000fe> Mono.CSharp.EmitContext:ResolveTopBlock
+in <0x00030> Mono.CSharp.EmitContext:EmitTopBlock
+in <0x0037a> Mono.CSharp.MethodData:Emit
+in <0x00022> Mono.CSharp.Method:Emit ()
+in <0x0057a> Mono.CSharp.TypeContainer:EmitType ()
+in <0x003e5> Mono.CSharp.RootContext:EmitCode ()
+in <0x00c48> Mono.CSharp.Driver:MainDriver (string[])
+in <0x0000f> Mono.CSharp.Driver:Main (string[])