Initializing 2D array (solved)

In my program I initialize two 2D arrays.

The first is initialized as it should in ROOT:

Int_t HPMask[3][3]; //HighPassFilterMask HPMask[0][0] = 0; HPMask[0][1] = -1; HPMask[0][2] = 0; HPMask[1][0] = -1; HPMask[1][1] = 5; HPMask[1][2] = -1; HPMask[2][0] = 0; HPMask[2][1] = -1; HPMask[2][2] = 0;

The second array is initialized inside a nested for-loop (there is more code in my loop in which I use ‘idx’ but this is not the problem):

for ( Int_t i = 1; i < (height-1); i++) //Looping through the picture { for ( Int_t j = 1; j < (width-1); j++) { Int_t idx[3][3]; //contains index of center pixel and its surrounding pixels idx[0][0]=((i-1)*width+j-1); idx[0][1]=((i-1)*width+j); idx[0][2]=((i-1)*width+j+1); idx[1][0]=(i*width+j-1); idx[1][1]=(i*width+j); idx[1][2]=(i*width+j+1); idx[2][0]=((i+1)*width+j-1); idx[2][1]=((i+1)*width+j); idx[2][2]=((i+1)*width+j+1); } }

This, however, results in the following error in ROOT:
“Array index out of range idx[0][0] -> [0] valid upto idx”.

When I compile the same code with my c++ compiler I get no errors or warnings.

I use ROOT 5.14/00 compiled on 14 December 2006 for Windows.

I isolated the code and made a test program, which I both compiled and tried to run in ROOT. The compiled version runs flawlessly as far as I can tell. The ROOT execution also works well (although a bit slower).

The problem in my full program still persists though.
BildeROOT.cpp (5.29 KB)

Sorry if I wasted anybody’s time but upgrading to 5.15 solved it. :slight_smile: