11-30-2008 08:53 PM
Is there any provision to have the CVI compiler (in debug) detect array indices that are out of bounds, when the array is multidimensional, and the out of bounds array index still ends up pointing to an element within the array?
Try this sample. The final loop index, i, goes over the declared dimension of 3, but a[0][i] still points to another location within the array:
#include <utility.h>
main()
{
int i, a[2][3];
for (i=0; i<3; i++) {
a[0][i] = i;
a[1][i] = 100+i;
}
for (i=0; i<6; i++) DebugPrintf("Dif = %i\n", a[0][i]);
}
Thanks,
Ian
Solved! Go to Solution.
12-01-2008 12:29 PM
Ian,
Unfortunately, the linker is not able to catch this in CVI during compile time, even with the maximum debug settings. I went ahead and put in a product suggestion for you though.
12-01-2008 04:21 PM
Thanks, Corbin. Not exactly what I was hoping for, but thanks for putting in the suggestion.
I'll be viewing all those multi-dimensional arrays I have with different eyes now!![]()
--Ian