Let's say we have an array:
struct some array[] = {A, B, C, D};
and lets say we have a function which, given an index by parameter, does something with that value:
void sfrugula(size_t index){
do_it( &array[index] );
}
now, we know we want to almost always call that function with STATIC values and not by variable, like:
sfugula(10);
is there a way to check that there is no overflow at compile time and if there is throw an error?
The point is to hard limit and check the parameter at compile time (if possible), as this may be applied not only on array but maybe even just to some variable.