[Mono-bugs] [Bug 31226][Nor] New - Rectangular array initialization fails on ref types

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
25 Sep 2002 20:11:32 -0000


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 larryo@thinkingin.net.

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

--- shadow/31226	Wed Sep 25 16:11:32 2002
+++ shadow/31226.tmp.1056	Wed Sep 25 16:11:32 2002
@@ -0,0 +1,74 @@
+Bug#: 31226
+Product: Mono/Runtime
+Version: unspecified
+OS: 
+OS Details: Windows XP Pro
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: larryo@thinkingin.net               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Rectangular array initialization fails on ref types
+
+Description of Problem:
+
+Using concrete assignment on RHS of rectanguler array declaration 
+compiles fine whether array stores value or ref. At runtime, however, if 
+the array is storing ref types, the Mono runtime throws an 
+IndexOutOfRangeException.
+
+Steps to reproduce the problem:
+//Mono defect
+using System;
+
+class IntHolder {
+  int i;
+
+  IntHolder(int i){
+    this.i=i;
+  }
+  public static void Main(){
+    // Array of value types:
+    int[,] a1 = {
+      { 1, 2 },
+      { 3, 4 },
+      { 5, 6},
+    };
+    Console.WriteLine("a1 is fine");
+    // Array of reference types:
+    IntHolder[,] a2 = {
+      { new IntHolder(1), new IntHolder(2)},
+      { new IntHolder(3), new IntHolder(4)},
+      { new IntHolder(5), new IntHolder(6)},
+    };
+    Console.WriteLine("a2 is fine");
+  }
+}
+
+Actual Results:
+
+a1 is fine
+
+Unhandled Exception: System.IndexOutOfRangeException: Index was outside 
+the bounds of the array.
+   at IntHolder.Main()
+
+Expected Results:
+
+a1 is fine
+a2 is fine
+
+How often does this happen? 
+
+Always.
+
+Additional Information:
+
+FWIW, I am working my way through the code in my book "Thinking in C#" 
+and trying to get it to run as appropriate with Mono.