[Mono-bugs] [Bug 688651] New: nullable enum is miscompiled

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Apr 19 21:42:00 EDT 2011



           Summary: nullable enum is miscompiled
    Classification: Mono
           Product: Mono: Compilers
           Version: SVN
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: C#
        AssignedTo: msafar at novell.com
        ReportedBy: spouliot at novell.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---

[mono] ~/src @ cat nullable-enum.cs 
using System;

enum E { Item };

class Program {
    static bool CheckNullableEnum (E? e)
        return e is Enum;

    static void Main (string [] args)
        Console.WriteLine (CheckNullableEnum (E.Item));

[mono] ~/src @ mcs nullable-enum.cs
nullable-enum.cs(10,26): warning CS0184: The given expression is never of the
provided (`System.Enum') type
Compilation succeeded - 1 warning(s)

^^^ CSC does not warn

    // method line 2
    .method private static hidebysig 
           default bool CheckNullableEnum (valuetype
[mscorlib]System.Nullable`1<valuetype E> e)  cil managed 
        // Method begins at RVA 0x2058
    // Code size 2 (0x2)
    .maxstack 8
    IL_0000:  ldc.i4.0 
    IL_0001:  ret 
    } // end of method Program::CheckNullableEnum

^^^ MCS warns and optimize this into a constant (returning false)

[mono] ~/src @ mono nullable-enum.exe 

^^^ MS.NET (well when the sample is compiled with CSC) returns: True

Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the mono-bugs mailing list