LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Debug mode: debug option to check array indices?

Solved!
Go to solution

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

0 Kudos
Message 1 of 3
(3,700 Views)
Solution
Accepted by topic author Ian.W

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.

Message 2 of 3
(3,670 Views)

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!Smiley Tongue

 

--Ian

0 Kudos
Message 3 of 3
(3,658 Views)