Bug 313478 (MONO52569) - MCS does not handle unboxing to {enum, value type}
Summary: MCS does not handle unboxing to {enum, value type}
Status: RESOLVED FIXED
Alias: MONO52569
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: unspecified
Hardware: Other Other
: P3 - Medium : Enhancement
Target Milestone: ---
Assignee: Mono Bugs
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2004-01-03 06:57 UTC by Ben Maurer
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
proposed patch (667 bytes, patch)
2004-01-03 07:58 UTC, Thomas Wiest
Details | Diff
new proposed patch (fixes typeof and (int)(Enum)Foo.Bar)) (737 bytes, patch)
2004-01-03 08:29 UTC, Thomas Wiest
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 18:23:06 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".