[Mono-bugs] [Bug 31289][Wis] New - mcs does not check bounds of multidimensional array initializers

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
26 Sep 2002 17:34:55 -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 hwang_rob@yahoo.ca.

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

--- shadow/31289	Thu Sep 26 13:34:55 2002
+++ shadow/31289.tmp.30843	Thu Sep 26 13:34:55 2002
@@ -0,0 +1,61 @@
+Bug#: 31289
+Product: Mono/MCS
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: Misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: hwang_rob@yahoo.ca               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: mcs does not check bounds of multidimensional array initializers
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+
+mcs does not report an error if a multidimensional array initializer is
+incorrectly formed with different lengths for each element of a dimension
+
+Steps to reproduce the problem:
+1. Compile the following with mcs:
+
+using System;
+
+public class ArrayTest
+{
+    public static void Main()
+    {
+        int[,] t = {{1,2,3,4},{5,6}};
+
+        for (int i = 0; i < t.GetLength(0); i++) {
+            for( int j = 0; j < t.GetLength(1); j++ ) {
+                Console.WriteLine( "{0},{1} = {2}", i, j, t[i,j] );
+            }
+        }
+    }
+}
+
+
+Actual Results:
+
+Compiles successfully.
+
+Expected Results:
+
+Should fail and give an error.
+
+How often does this happen? 
+
+Always.
+
+Additional Information:
+
+Will attach a patch to method CheckIndices of class ArrayCreation in
+expression.cs (1.357) which I believe fixes the problem.