www.digitalmars.com         C & C++   DMDScript  

D - dmd Beta v0.67 Error

The following program issues an ArrayBoundsError.
The index being accessed is well with bounds.

struct Map
{
  int width;
  int height;
  int[][] grid;
}

void WalkPath(Map map)
{
  while(true)
  {
  
    void TestXY(int x, int y)
    {
      if(map.grid[y][x] > 0) // Array bounds error here
      {
      }
    }
    
    TestXY(5,5);
    break;
      
  }
}


int main(char[][] argv)
{
  Map map;

  map.grid.length = 10;
  for(int y = 0; y < 10; ++y)
    map.grid[y].length = 10;

  WalkPath(map);

  
  return 0;
}
Jun 29 2003