[Mono-bugs] [Bug 342584] Cast from IntPtr to Enum fails with CS0030

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Nov 19 08:05:45 EST 2007


--- Comment #2 from Marek Safar <msafar at novell.com>  2007-11-19 06:05:45 MST ---
csc produces this

  IL_0001:  ldloca.s   V_0
  IL_0003:  ldc.i4.1
  IL_0004:  call       instance void [mscorlib]System.IntPtr::.ctor(int32)
  IL_0009:  nop
  IL_000a:  ldloc.0
  IL_000b:  call       int32 [mscorlib]System.IntPtr::op_Explicit(native int)
  IL_0010:  stloc.1
  IL_0011:  ret

so there is an explicit operator call. However following code is exactly same
except it uses custom type instead of IntPtr and it gets rejected by csc.
This looks like another csc weirdness.

Secondly changing enum base type to ulong has no effect and csc still uses
explicit int32 (IntPtr) conversion and then conv.i8

enum Key

struct S
        public static explicit operator int (S val)
                return 1;

class C
        E Foo ()
                S s = new S ();
                return (Key) s;

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