Possible Duplicate:
Why don’t I get a segmentation fault when I write beyond the end of an array?
This code compiles and runs without any error. But how?
#include <stdio.h>
int main (void)
{
int foo[2];
foo[8] = 4; /* How could this happen? */
printf("%d\n", foo[8]);
return 0;
}
I'm compiling with GCC 4.7.2 on Arch Linux x86_64.
gcc -Wall -o "main" "main.c"