25 lines
626 B
C
25 lines
626 B
C
|
#include<stdio.h>
|
||
|
int main()
|
||
|
{
|
||
|
int arr[2];
|
||
|
arr[0] = 0;
|
||
|
arr[2] = 2; //compcert gave no error!
|
||
|
printf("arr[0] = %d\n", arr[0]);
|
||
|
printf("arr[2] = %d\n", arr[2]); //compcert still gave no error!!
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
Gave error like gcc when I tried using printf without header file:
|
||
|
|
||
|
arr-bounds-out.c:6: warning: implicit declaration of function 'printf' is invalid in C99 [-Wimplicit-function-declaration]
|
||
|
arr-bounds-out.c:6: warning: 'printf' is declared without a function prototype
|
||
|
*/
|
||
|
|
||
|
/*
|
||
|
Out of bound array access gave no error! Instead printed the value:
|
||
|
|
||
|
arr[0] = 0
|
||
|
arr[2] = 2
|
||
|
*/
|