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 [EMAIL PROTECTED] http://bugzilla.ximian.com/show_bug.cgi?id=80256 --- shadow/80256 2006-12-13 17:34:22.000000000 -0500 +++ shadow/80256.tmp.26318 2006-12-13 17:34:22.000000000 -0500 @@ -0,0 +1,74 @@ +Bug#: 80256 +Product: Mono: Compilers +Version: 1.0 +OS: +OS Details: +Status: NEW +Resolution: +Severity: +Priority: Normal +Component: C# +AssignedTo: [EMAIL PROTECTED] +ReportedBy: [EMAIL PROTECTED] +QAContact: [EMAIL PROTECTED] +TargetMilestone: --- +URL: +Cc: +Summary: Switch with different types crashes the compiler + +The following test crashes the compiler because our there are mixed data +types in the resulting array: +enum ByteEnum : byte { + One = 1, + Two = 2 +} + +class X { + static void Main () + { + ByteEnum b = ByteEnum.One; + + switch (b){ + case ByteEnum.One : return; + case ByteEnum.One | ByteEnum.Two: return; + } + } +} + +Stacktrace: +Unhandled Exception: System.InvalidOperationException: The comparer threw +an exception. ---> System.ArgumentException: Value is not a System.Byte. + at System.Byte.CompareTo (System.Object value) [0x00000] + at System.Array.compare (System.Object value1, System.Object value2, +IComparer comparer) [0x00000] + at System.Array.qsort (System.Array keys, System.Array items, Int32 low0, +Int32 high0, IComparer comparer) [0x00000] + at System.Array.Sort (System.Array keys, System.Array items, Int32 index, +Int32 length, IComparer comparer) [0x00000] --- End of inner exception +stack trace --- + + at System.Array.Sort (System.Array keys, System.Array items, Int32 index, +Int32 length, IComparer comparer) [0x00000] + at System.Array.Sort (System.Array array) [0x00000] + at Mono.CSharp.Switch.TableSwitchEmit (Mono.CSharp.EmitContext ec, +System.Reflection.Emit.LocalBuilder val) [0x00000] + at Mono.CSharp.Switch.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] + at Mono.CSharp.Statement.Emit (Mono.CSharp.EmitContext ec) [0x00000] + at Mono.CSharp.Block.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] + at Mono.CSharp.Block.Emit (Mono.CSharp.EmitContext ec) [0x00000] + at Mono.CSharp.EmitContext.EmitResolvedTopBlock +(Mono.CSharp.ToplevelBlock block, Boolean unreachable) [0x00000] + at Mono.CSharp.EmitContext.EmitTopBlock (IMethodData md, +Mono.CSharp.ToplevelBlock block) [0x00000] + at Mono.CSharp.MethodData.Emit (Mono.CSharp.DeclSpace parent) [0x00000] + at Mono.CSharp.Method.Emit () [0x00000] + at Mono.CSharp.TypeContainer.EmitType () [0x00000] + at Mono.CSharp.RootContext.EmitCode () [0x00000] + at Mono.CSharp.Driver.MainDriver (System.String[] args) [0x00000] + at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] + +An instrumented version of the compiler shows: + +mono$ gmcs cs.cs +Value 1 System.Byte +Value 3 System.Int32 _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
