[Mono-bugs] [Bug 78584][Nor] New - implicit operator on structs
issue
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Mon Jun 5 11:07:33 EDT 2006
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 joe at otee.dk.
http://bugzilla.ximian.com/show_bug.cgi?id=78584
--- shadow/78584 2006-06-05 11:07:33.000000000 -0400
+++ shadow/78584.tmp.7244 2006-06-05 11:07:33.000000000 -0400
@@ -0,0 +1,47 @@
+Bug#: 78584
+Product: Mono: Compilers
+Version: 1.1
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: C#
+AssignedTo: rharinath at novell.com
+ReportedBy: joe at otee.dk
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: implicit operator on structs issue
+
+The following C# program should print 1 but prints 0 instead.
+Strangely enough moving
+static private LayerMask mask = 1; makes the problem disappear.
+
+
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+[StructLayout (LayoutKind.Sequential)]
+public struct LayerMask
+{
+ private ushort m_Mask;
+ public static implicit operator int (LayerMask mask) { return (int)mask.m_Mask; }
+ public static implicit operator LayerMask (int intVal) { LayerMask mask; mask.m_Mask =
+unchecked ((ushort)intVal); return mask; }
+}
+
+class Test
+{
+ static private LayerMask mask = 1;
+
+ static void Main ()
+ {
+ int value = mask;
+ System.Console.WriteLine("Output {0}", value);
+ }
+}
More information about the mono-bugs
mailing list