Why doesn't the compiler warns me about an obvious error?

后端 未结 5 1466
清歌不尽
清歌不尽 2020-12-12 07:48

So, I just studied the Arrays material and got a problem...
I got this following code:

int a[5]; 
int i;
for(i=0; i<=10; i++) {
             


        
5条回答
  •  时光说笑
    2020-12-12 08:25

    C doesn't have any standard on constraint on array index out of bound checking.

    That means programs are free to violate the index rule. It is upto the programmers to check the array index constraint.

    And, that will result in an undefined behaviour.

提交回复
热议问题