Yeah gcc can hide the errors sometimes
It's not GCC...
Check this code:
#include <stdio.h>
int main() {
int before1 = 0;
int before2 = 0;
int a[0];
int after1 = 0;
int after2 = 0;
printf("before: %d %d, after: %d %d.\n", before1, before2, after1, after2);
a[0] = 42;
printf("before: %d %d, after: %d %d.\n", before1, before2, after1, after2);
return 0;
}
I declared an array of int of size 0, and a out-of-boundary write happened after that a[0] = 42;.
The result might be:
before: 0 0, after: 0 0.
before: 0 0, after: 0 42.
See? There might be no run time error, but the result of the program is wrong. As you could see, after2 is modified unexpectedly to 42.