Problem: Wrong protection "index out of bounds" in rev.103?

22 Jul 2015

Hello, I have encountered problem with protection against wrong indexing in arrays.

This emits error during compilation.

int arr[4] = {1,2,3,4};
arr[5] = 13;

But this not

int arr[4] = {1,2,3,4};
arr[4] = 13;

when LPC1768 reach that point, it stop working, no error LED signal occurs, it just stop working without a jack. This occurs only in rev 103

22 Jul 2015

This looks more like a compiler issue than something related to the library version, whether the mbed library was included or not shouldn't have any impact on the code you gave.

Either way you should never count on the compiler catching out of bounds array accesses because it's always going to miss some. And c doesn't provide any run time protection, if you try to access element 500 of a 10 item array it will happily give you a gibberish value. As with most things ultimately it is up to the programmer to not write invalid code.