22.11.2014, 11:12
(
Последний раз редактировалось CutX; 14.12.2014 в 15:57.
)
Quote:
Originally Posted by iThePunisher
[12:52:09] [debug] Run time error 4: "Array index out of bounds"
[12:52:09] [debug] Accessing element at index 999 past array upper bound 2 |
this can be caused by something like this
pawn Код:
new vect[5];//0 - 4
for(new i=0; i<6; i++)//throws an out of bounds error during crash detect scan
printf("%d",vect[i]);//cuz vect's boundaries are ranging from 0 to 4 (not 5)
//it'll loop 0 to 5 until it crashes at i = 5 if we say i<6
//it'll be like: print, print, print, print, print, CRASHHHHH
pawncc won't run loops to check if theyre allright.
but on the other hand, something like this
pawn Код:
new vect[5];
new x = vect[5];
knows the boundaries of vect are from 0 to 4 after "new vect[5]".
So if it's scanning something like "new x = vect[5]", itll look up
the boundaries of "vect" in the pool and "barks" if its out of range.
you'd get this error message
Код:
error 32: array index out of bounds (variable "vect")
which could cause the accessing of an invalid element as described above.