Why am I able to add values that are out of bounds of my array index?[SOLVED]

I don't understand why this works:

int test[10];

void setup()
  test[30] = 10;


why am I able to write something to index 30... when I clearly defined my array with the size of 10?

Does arrays have dynamic sizes in c?

The memory you are writing to exists, but it is not occupied by your array.

Basically test[30] = ...; means write to the memory located at the pointer to 'test' + 30.

However there is a catch. While you can write to that memory, you can't guarantee that that memory is not occupied by something else. Generally out of bounds access tends to lead to memory corruption and possibly stack corruption which would cause the processor to crash and reset back to the start of the program.

Ok, thx a lot for the answer. Everything is much more clear now. I was just wondering why I didn't get an error while compiling :)