Bug 321473 (MONO78752) - [GMCS] cast from object to nullable type causes NullReferenceException
Summary: [GMCS] cast from object to nullable type causes NullReferenceException
Status: RESOLVED FIXED
Alias: MONO78752
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 1.1
Hardware: Other Other
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Martin Baulig
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-03 17:47 UTC by Atsushi Enomoto
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 20:02:33 UTC


---- Reported by atsushi@ximian.com 2006-07-03 10:47:21 MST ----

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.



---- Additional Comments From martin@ximian.com 2006-07-05 11:10:21 MST ----

Already fixed :-)


Unknown operating system unknown. Setting to default OS "Other".