Bugzilla – Bug 321313
[PPC] implicit operator on structs issue
Last modified: 2010-03-21 12:02:58 UTC
---- Reported by joe@otee.dk 2006-06-05 11:07:32 MST ---- 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); } } ---- Additional Comments From rharinath@novell.com 2006-06-08 08:26:56 MST ---- I cannot reproduce the error with a recent SVN version of the compiler. Can you provide more details about the version of the compiler and the runtime? ---- Additional Comments From joe@otee.dk 2006-06-30 09:56:40 MST ---- This happens with mono 1.1.15 on mac os x ppc 10.4.6. ---- Additional Comments From rharinath@novell.com 2006-07-03 10:15:13 MST ---- Can you verify with a newer snapshot. If the problem persists, it may have to do with some endian-ness issue (I don't have access to a big-endian machine to verify). ---- Additional Comments From joe@otee.dk 2006-09-22 14:49:05 MST ---- I tried with 1.1.17.1 and the problem still appears. ---- Additional Comments From joe@otee.dk 2006-09-22 14:49:33 MST ---- I only tried on ppc. ---- Additional Comments From joe@otee.dk 2006-11-20 12:28:46 MST ---- I just tested on a ppc machine with mono 1.2 again. The bug is still there. Any idea when this will be fixed? ---- Additional Comments From marek.safar@seznam.cz 2006-11-30 16:34:01 MST ---- It prints Output 1 on x86. So it looks like runtime issue. -> reassigning Unknown operating system unknown. Setting to default OS "Other".
This works fine with recent mono versions on ppc.