[Mono-bugs] [Bug 76921][Min] New - Enum.FormatFlags fails to
properly handle the "No bits set" case
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Mon Dec 5 15:24:49 EST 2005
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by peter at novonyx.com.
http://bugzilla.ximian.com/show_bug.cgi?id=76921
--- shadow/76921 2005-12-05 15:24:49.000000000 -0500
+++ shadow/76921.tmp.28559 2005-12-05 15:24:49.000000000 -0500
@@ -0,0 +1,51 @@
+Bug#: 76921
+Product: Mono: Class Libraries
+Version: 1.1
+OS: All
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Minor
+Component: CORLIB
+AssignedTo: mono-bugs at ximian.com
+ReportedBy: peter at novonyx.com
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Enum.FormatFlags fails to properly handle the "No bits set" case
+
+Running the code below, you would expect to get
+ None
+ One
+as the result, like on MS.Net. However, Mono returns
+ None,
+ None, one
+instead, since Enum.cs sorts the enum values by numbers and subsequently
+assumes that the "No bits set" value (0) is at position 0. However,
+the "Negative" enum item causes that assumption to fail.
+
+I've attached a patch. I removed the assumption from all types (not just
+the signed ones) for consistency.
+
+using System;
+
+public class FlagsTest {
+ [Flags]
+ enum TestEnum {
+ None = 0,
+ One = 1,
+ Two = 2,
+ Negative = unchecked((int)0xFFFF0000)
+ }
+
+ static void Main() {
+ TestEnum t;
+
+ t = TestEnum.None;
+ Console.WriteLine("Enum: {0}", t);
+ t = TestEnum.One;
+ Console.WriteLine("Enum: {0}", t);
+ }
+}
More information about the mono-bugs
mailing list