[Mono-devel-list] [Bug] Mono exception handling in multidimensional arrays

Saajan Singh Chana saajan at saajmin.f9.co.uk
Wed Jun 4 07:18:50 EDT 2003


Hi,

I recently noticed that mono seems to incorrectly handle 
IndexOutOfRangeExceptions in multidimensional arrays.  The following 
code demonstrates the error:

using System;

class ArrayExceptionTest
{
  public static void Main(string[] args)
  {
   try
   {
    bool[] array = new bool[2];
    array[-1] = true;
   }
   catch(IndexOutOfRangeException)
   {
    Console.Out.WriteLine("Caught IndexOutOfRangeException on 
one-dimensional array; works on mono and .NET");
   }
   try
   {
    bool[,] array = new bool[3,3];
    array[-1,0] = true;
   }
   catch(Exception)
   {
    Console.Out.WriteLine("Caught IndexOutOfRangeException on 
two-dimensional array; only works on .NET");
   }
  }
}

It compiles fine, and the first try..catch works fine on both mono and 
.NET.  However, the second try..catch works on .NET but on mono the 
program crashes with the message

Unhandled Exception: System.IndexOutOfRangeException: Array index is out 
of range.

Apart from that, you guys are doing a great job.  Keep it up!

Saajan





More information about the Mono-devel-list mailing list