[Mono-bugs] [Bug 44978][Wis] New - Array.Copy throws wrong exceptions
bugzilla-daemon@rocky.ximian.com
bugzilla-daemon@rocky.ximian.com
Tue, 17 Jun 2003 07:29:03 -0400 (EDT)
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 tum@veridicus.com.
http://bugzilla.ximian.com/show_bug.cgi?id=44978
--- shadow/44978 Tue Jun 17 07:29:03 2003
+++ shadow/44978.tmp.6663 Tue Jun 17 07:29:03 2003
@@ -0,0 +1,93 @@
+Bug#: 44978
+Product: Mono/MCS
+Version: unspecified
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Wishlist
+Component: Misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: tum@veridicus.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Array.Copy throws wrong exceptions
+
+Description of Problem:
+
+Array.Copy should throw ArgumentOutOfRangeExceptions when the supplied
+index and count are "out of range" rather than ArgumentExceptions.
+
+Steps to reproduce:
+
+Run the following program...
+
+using System;
+
+public class Test
+{
+ public static void Main()
+ {
+ object[] array = new object[100];
+
+ Array.Copy(array, -1, array, -1, 0);
+ }
+}
+
+
+Actual Results:
+
+ArgumentException is thrown.
+
+Expected Results:
+
+ArgumentOutOfRangeException should be thrown.
+
+Additional Information:
+
+Patch:
+
+Index: Array.cs
+===================================================================
+RCS file: /mono/mcs/class/corlib/System/Array.cs,v
+retrieving revision 1.49
+diff -u -r1.49 Array.cs
+--- Array.cs 29 May 2003 02:32:38 -0000 1.49
++++ Array.cs 17 Jun 2003 11:27:11 -0000
+@@ -133,9 +133,9 @@
+ internal extern void SetValueImpl (object value, int pos);
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+- internal extern static bool FastCopy (Array source, int
+source_idx, Array dest, int dest_idx, int length);
+-
+- [MethodImplAttribute(MethodImplOptions.InternalCall)]
++ internal extern static bool FastCopy (Array source, int
+source_idx, Array dest, int dest_idx, int length);
++
++ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ internal extern static Array CreateInstanceImpl(Type
+elementType, int[] lengths, int [] bounds);
+
+ // Properties
+@@ -482,10 +482,10 @@
+ throw new ArgumentOutOfRangeException
+("length");
+
+ if (source_idx < 0)
+- throw new ArgumentException
+("source_idx");
++ throw new ArgumentOutOfRangeException
+("source_idx");
+
+ if (dest_idx < 0)
+- throw new ArgumentException ("dest_idx");
++ throw new ArgumentOutOfRangeException
+("dest_idx");
+
+ if (FastCopy (source, source_idx, dest, dest_idx,
+length))
+ return;