[Mono-bugs] [Bug 74862][Nor] New - gmcs: NullReferenceException when using 'default'

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sat, 7 May 2005 13:56:03 -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 i.kasiuk@ngi.de.

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

--- shadow/74862	2005-05-07 13:56:03.000000000 -0400
+++ shadow/74862.tmp.17778	2005-05-07 13:56:03.000000000 -0400
@@ -0,0 +1,59 @@
+Bug#: 74862
+Product: Mono: Compilers
+Version: 1.1
+OS: 
+OS Details: FC3 x86_64 on AMD64
+Status: NEW   
+Resolution: 
+Severity: Unknown
+Priority: Normal
+Component: C#
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: i.kasiuk@ngi.de               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: gmcs: NullReferenceException when using 'default'
+
+Compile the following code with gmcs (using version 1.1.7):
+
+----------------------------------------------
+class B<T> 
+{
+    T t = default(T);
+}
+
+class Test
+{
+    public static void Main() { }
+}
+----------------------------------------------
+
+The compiler produces an exception:
+
+Unhandled Exception: System.NullReferenceException: Object reference not
+set to an instance of an object
+in <0x0012d> Mono.CSharp.EmitContext:GetTemporaryLocal (System.Type t)
+in <0x0006d> Mono.CSharp.LocalTemporary:.ctor (Mono.CSharp.EmitContext ec,
+System.Type t, Boolean is_address)
+in <0x00012> Mono.CSharp.LocalTemporary:.ctor (Mono.CSharp.EmitContext ec,
+System.Type t)
+in <0x00078> Mono.CSharp.DefaultValueExpression:DoResolve
+(Mono.CSharp.EmitContext ec)
+in <0x000ec> Mono.CSharp.FieldBase:GetInitializerExpression
+(Mono.CSharp.EmitContext ec)
+in <0x00101> Mono.CSharp.TypeContainer:EmitFieldInitializers
+(Mono.CSharp.EmitContext ec)
+in <0x002c8> Mono.CSharp.Constructor:Emit ()
+in <0x004e5> Mono.CSharp.TypeContainer:EmitType ()
+in <0x00249> Mono.CSharp.RootContext:EmitCode ()
+in <0x00bd3> Mono.CSharp.Driver:MainDriver (System.String[] args)
+in <0x0001f> Mono.CSharp.Driver:Main (System.String[] args)
+
+
+Expected Results:
+successful compilation
+
+How often does this happen? 
+always