Bugzilla – Bug 313478
MCS does not handle unboxing to {enum, value type}
Last modified: 2007-09-15 21:24:23 UTC
---- Reported by bmaurer@users.sf.net 2004-01-02 23:57:45 MST ---- Description of Problem: (Modified from Todd's report on the ML) using System; enum Foo { Bar } class T { static void Main () { Enum e = Foo.Bar; ValueType vt = Foo.Bar; Console.WriteLine ((Foo)e == Foo.Bar); Console.WriteLine ((Foo)vt == Foo.Bar); } } Here we are printing `false false' we should return `true true' The issue is we are emitting castclass not unbox. ---- Additional Comments From bmaurer@users.sf.net 2004-01-03 00:14:22 MST ---- Ok, this adds another version: using System; enum Foo { Bar } struct T { static void Main () { Enum e = Foo.Bar; ValueType vt = Foo.Bar; ValueType vt2 = 1; Console.WriteLine ((Foo)e == Foo.Bar); Console.WriteLine ((Foo)vt == Foo.Bar); Console.WriteLine ((int) vt2); } } Again, we generate castclass, which is invalid (note that Mono errors out while MS emits the address of the boxed instance, is this another bug?) ---- Additional Comments From pcgod@gmx.net 2004-01-03 00:58:43 MST ---- Created an attachment (id=165406) proposed patch ---- Additional Comments From pcgod@gmx.net 2004-01-03 01:29:04 MST ---- Created an attachment (id=165407) new proposed patch (fixes typeof and (int)(Enum)Foo.Bar)) ---- Additional Comments From bmaurer@users.sf.net 2004-01-03 12:38:48 MST ---- patch in cvs and test-case-ized. Imported an attachment (id=165406) Imported an attachment (id=165407) Unknown operating system unknown. Setting to default OS "Other".