[Mono-bugs] [Bug 81807][Nor] New - Switch on nullable enum produces broken IL code

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Mon Jun 4 18:15:15 EDT 2007


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 lars at ahlzen.com.

http://bugzilla.ximian.com/show_bug.cgi?id=81807

--- shadow/81807	2007-06-04 18:15:15.000000000 -0400
+++ shadow/81807.tmp.25649	2007-06-04 18:15:15.000000000 -0400
@@ -0,0 +1,64 @@
+Bug#: 81807
+Product: Mono: Compilers
+Version: 1.2
+OS: GNU/Linux [Other]
+OS Details: Gentoo
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: C#
+AssignedTo: rharinath at novell.com                            
+ReportedBy: lars at ahlzen.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Switch on nullable enum produces broken IL code
+
+With a switch on a nullable enum type, the compiler seems to generate some
+broken IL code.
+
+Here is a simple code snippet to reproduce the issue:
+
+using System;
+public enum TestEnum { Value1, Value2 }
+public class TestClass
+{
+	public static void Main()
+	{
+		Console.WriteLine("Alive so far...");
+		TestEnum? testEnum = TestEnum.Value1;
+		switch (testEnum) {
+			case TestEnum.Value1:
+				Console.WriteLine("Value 1");
+				break;
+		}		
+	}
+}
+
+
+Running this (with Mono 1.2.4) consistently gives me the following result:
+
+lars at saturn ~/projects/wx $ gmcs testcase.cs
+lars at saturn ~/projects/wx $ mono ./testcase.exe 
+
+Unhandled Exception: System.InvalidProgramException: Invalid IL code in
+TestClass:Main (): IL_001a: brfalse   IL_ffffffff
+
+
+Apparently, it crashes before execution reaches Console.WriteLine line.
+
+
+Compiling and running it with Microsoft .NET (version info below) produces
+the following (expected) result:
+
+Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.42
+for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727
+Copyright (C) Microsoft Corporation 2001-2005. All rights reserved.
+
+Alive so far...
+Value 1
+
+
+Please adjust severity and priority as appropriate.


More information about the mono-bugs mailing list