Bug 1025 - Compiler crashes on switch with case ulong.MaxValue
Summary: Compiler crashes on switch with case ulong.MaxValue
Status: RESOLVED FIXED
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2011-09-24 02:45 UTC by Phil Garcia
Modified: 2012-06-06 05:03 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Phil Garcia 2011-09-24 02:45:18 UTC
The following method crashes the compiler:

public static ulong SwitchU8(ulong a)
{
	switch (a)
	{
		case ulong.MaxValue:
			return 0;
		default:
			return 1;
	}
}

Here's the error message (method above was included in new empty project):

Internal compiler error at Main.cs(7,29):: exception caught while emitting MethodBuilder [MainClass::SwitchU8]
Unhandled Exception: System.OverflowException: Number overflow.
  at System.UInt64.System.IConvertible.ToInt64 (IFormatProvider provider) [0x00000] in <filename unknown>:0
  at System.Convert.ToInt64 (System.Object value, IFormatProvider provider) [0x00000] in <filename unknown>:0
  at System.Convert.ToInt64 (System.Object value) [0x00000] in <filename unknown>:0
  at Mono.CSharp.Switch.TableSwitchEmit (Mono.CSharp.EmitContext ec, Mono.CSharp.Expression val) [0x00000] in <filename unknown>:0
  at Mono.CSharp.Switch.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0
  at Mono.CSharp.Statement.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0
  at Mono.CSharp.Block.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0
  at Mono.CSharp.Block.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0
  at Mono.CSharp.ExplicitBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filenameunknown>:0
  at Mono.CSharp.ToplevelBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filenameunknown>:0
  at Mono.CSharp.MethodData.Emit (Mono.CSharp.DeclSpace parent) [0x00000] in <filename unknown>:0
  at Mono.CSharp.MethodOrOperator.Emit () [0x00000] in <filename unknown>:0
  at Mono.CSharp.Method.Emit () [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.OverflowException: Number overflow.
  at System.UInt64.System.IConvertible.ToInt64 (IFormatProvider provider) [0x00000] in <filename unknown>:0
  at System.Convert.ToInt64 (System.Object value, IFormatProvider provider) [0x00000] in <filename unknown>:0
  at System.Convert.ToInt64 (System.Object value) [0x00000] in <filename unknown>:0
  at Mono.CSharp.Switch.TableSwitchEmit (Mono.CSharp.EmitContext ec, Mono.CSharp.Expression val) [0x00000] in <filename unknown>:0
  at Mono.CSharp.Switch.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0
  at Mono.CSharp.Statement.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0
  at Mono.CSharp.Block.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0
  at Mono.CSharp.Block.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0
  at Mono.CSharp.ExplicitBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filenameunknown>:0
  at Mono.CSharp.ToplevelBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filenameunknown>:0
  at Mono.CSharp.MethodData.Emit (Mono.CSharp.DeclSpace parent) [0x00000] in <filename unknown>:0
  at Mono.CSharp.MethodOrOperator.Emit () [0x00000] in <filename unknown>:0
  at Mono.CSharp.Method.Emit () [0x00000] in <filename unknown>:0
Comment 1 Marek Safar 2011-09-24 04:03:09 UTC
Already fixed in master
Comment 2 Phil Garcia 2012-06-06 05:02:31 UTC
This is still not resolved in 2.10.5. I do not believe this has been fixed in master.
Comment 3 Marek Safar 2012-06-06 05:03:52 UTC
It has been fixed in Mono 2.11 or newer