[Mono-bugs] [Bug 71905][Nor] New - Pre-Incrementing vars as method parameters increment too early in certain cases

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Fri, 28 Jan 2005 08:36:27 -0500 (EST)


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 aksdb@gmx.de.

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

--- shadow/71905	2005-01-28 08:36:27.000000000 -0500
+++ shadow/71905.tmp.13884	2005-01-28 08:36:27.000000000 -0500
@@ -0,0 +1,71 @@
+Bug#: 71905
+Product: Mono: Runtime
+Version: 1.1
+OS: Debian Woody
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: aksdb@gmx.de               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Pre-Incrementing vars as method parameters increment too early in certain cases
+
+Description of Problem:
+I've only tested the problem in the following example - I don't know which
+other cases are also affected.
+If I parse through an string[] array and give the current string
+array[index] along with the ++index as a method parameter, the array
+position is also increased, although the ++index was given to the method as
+a subsequent parameter and not preceding.
+
+Steps to reproduce the problem:
+namespace IncrementTest
+{
+	public class IncTest
+	{
+		static string[] testarray = new string[]
+		{
+			"1",
+			"2",
+			"3"
+		};
+		
+		public static void Main( string[] args )
+		{
+			int index = 0;
+			for ( int i = 0; i < testarray.Length; ++i )
+				PrintResult( testarray[index], ++index );
+		}
+		
+		public static void PrintResult( string content, int index )
+		{
+			Console.WriteLine( "{0}: {1}", index, content );
+		}
+	}
+}
+
+Actual Results:
+1: 2
+2: 3
+
+Unhandled Exception: System.IndexOutOfRangeException: Array index is out of
+range.
+in <0x0001d> IncrementTest.IncTest:Main (string[]) 
+
+Expected Results:
+1: 1
+2: 2
+3: 3
+
+How often does this happen? 
+Everytime I tested it on the current Mono versions. (1.1.3 from svn)
+
+Additional Information:
+It works perfectly on older Mono versions (tested on 1.0.1 on windows) and
+the MS .NET Framework.