[Mono-bugs] [Bug 78752][Nor] New - [GMCS] cast from object to nullable type causes NullReferenceException

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Mon Jul 3 10:47:21 EDT 2006


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 atsushi at ximian.com.

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

--- shadow/78752	2006-07-03 10:47:21.000000000 -0400
+++ shadow/78752.tmp.3568	2006-07-03 10:47:21.000000000 -0400
@@ -0,0 +1,56 @@
+Bug#: 78752
+Product: Mono: Compilers
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: C#
+AssignedTo: martin at ximian.com                            
+ReportedBy: atsushi at ximian.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: [GMCS] cast from object to nullable type causes NullReferenceException
+
+The following code when compiled with gmcs causes NullReferenceException,
+while with csc it does not.
+
+--------
+using System;
+
+public class Tset
+{
+        public static void Main ()
+        {
+                Foo ();
+        }
+
+        static object obj;
+
+        static bool? Foo ()
+        {
+                return (bool?) obj;
+        }
+}
+
+
+Actual Results:
+
+mono ./nullable-cast.exe
+
+Unhandled Exception: System.NullReferenceException: Object reference not set to
+an instance of an object
+  at Tset.Foo () [0x00000]
+  at Tset.Main () [0x00000]
+
+Expected Results:
+
+no error.
+
+How often does this happen? 
+
+consistently.


More information about the mono-bugs mailing list