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 [EMAIL PROTECTED]

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

--- shadow/82247        2007-07-31 04:21:17.000000000 -0400
+++ shadow/82247.tmp.19390      2007-07-31 04:21:17.000000000 -0400
@@ -0,0 +1,102 @@
+Bug#: 82247
+Product: Mono: Compilers
+Version: 1.2
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: C#
+AssignedTo: [EMAIL PROTECTED]                            
+ReportedBy: [EMAIL PROTECTED]               
+QAContact: [EMAIL PROTECTED]
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: casting multidimensional jagged arrays swaps order on return
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+
+  When casting multi-dimensional jagged arrays, the cast seems to reverse
+the order of the arrays. Eg, [,][] (a 2 dimensional jagged array), gets
+casted to [][,].
+
+Note below that Clone works in terms of returning the correct order of
+arrays. I've also included a simple function to do the same thing, just to
+show that the Clone itself isn't the problem - it's the cast. If we don't
+cast, then it compiles fine.
+
+Steps to reproduce the problem:
+
+using System;
+namespace mono_bug {
+       class Program {
+               static void Main(string[] args) {
+                       
+                       // initialise so no null errors
+                       double[,][] foo = new double[1,1][];
+                       foo[0,0] = new double[2];
+                       
+                       double[,][] bar;
+
+                       // fails with error CS0029:
+                       // Cannot implicitly convert type `double[,][]' to 
`double[][,]'
+                       bar = (double[,][])foo.Clone();
+               
+                       // also fails with error CS0029:
+                       // Cannot implicitly convert type `double[,][]' to 
`double[][,]'
+                       bar = (double[,][])ReturnArray();
+
+                       // compiles & works correctly
+                       bar = ReturnArray();
+
+                       Console.WriteLine(bar[0,0][1].ToString());
+                       
+                       
+               }
+               
+               private static double[,][] ReturnArray() {
+               // just creates a "useless", multi-dimensional jagged array
+                       double[,][] zoo = new double[1,1][];
+                       zoo[0,0] = new double[2];
+                       zoo[0,0][0] = 1;
+                       zoo[0,0][1] = 2;
+                       return zoo;
+               }
+       
+       }
+}
+
+
+Actual Results:
+
+/usr/bin/mono /usr/lib/mono/2.0/gmcs.exe
+-out:/home/si/code/mono/mono_bug/bin/Debug/mono_bug.exe -noconfig+
+-target:exe -debug+ -define:DEBUG;TRACE
+-reference:/usr/lib/mono/2.0/System.dll
+-reference:/usr/lib/mono/2.0/System.Data.dll
+-reference:/usr/lib/mono/2.0/System.Xml.dll
+"/home/si/code/mono/mono_bug/Program.cs" 
+/home/si/code/mono/mono_bug/Program.cs(15,25): error CS0029: Cannot
+implicitly convert type `double[,][]' to `double[][,]'
+/home/si/code/mono/mono_bug/Program.cs(19,57): error CS0030: Cannot convert
+type `double[][,]' to `double[,][]'
+Compilation failed: 2 error(s), 0 warnings
+
+
+
+Expected Results:
+
+  Should compile correctly. .NET does.
+
+
+How often does this happen? 
+
+  Every time.
+
+Additional Information:
+
+  Note that it's the explicit cast that causes the compiler to fail.
_______________________________________________
mono-bugs maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs

Reply via email to