Bug 29183

Summary: Array constructor fails to construct multi bound array
Product: [Mono] Runtime Reporter: Marek Safar <masafa>
Component: ReflectionAssignee: Bugzilla <bugzilla>
Status: RESOLVED FIXED    
Severity: normal CC: mono-bugs+runtime, vargaz
Priority: ---    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:

Description Marek Safar 2015-04-17 06:17:25 UTC
using System.Reflection;
using System;
using System.Linq;

class X
{
	public static void Main ()
	{
		var type1 = Type.GetType ("System.Char[,]").GetTypeInfo ();
		var ci = type1.DeclaredConstructors.First (l => l.GetParameters ().Length == 4);
		var res = ci.Invoke (new object[] { 1, 5, -10, 7 });
	}
}

Unhandled Exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.OverflowException: Arithmetic operation resulted in an overflow.
  at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
  at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00009] in /Users/marek/git/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:651 
  --- End of inner exception stack trace ---
  at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00018] in /Users/marek/git/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:657 
  at System.Reflection.MonoCMethod.DoInvoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x000a1] in /Users/marek/git/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:642 
  at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00008] in /Users/marek/git/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:670 
  at System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) [0x00016] in
Comment 1 Zoltan Varga 2015-04-17 13:19:40 UTC
Shouldn't the lower bounds come first, and the lengths after them ?
Comment 2 Marek Safar 2015-04-17 14:04:21 UTC
Yes, so it should create an array of char[1..5, -10..-4]
Comment 3 Zoltan Varga 2015-04-17 15:06:14 UTC
Fixed in mono master 8de00a141d127352e2af3dba91dd1860791e05ba.