Here is a sample code:
#include <stdio.h>
int main() {
int n = 5;
float v[n];
float sum;
int i;
for(i = 0; i < n; i++) {
v[i] = i + 1;
printf("v[%d]=%f\n", i, v[i]);
}
for(i = 0; i < n; i++) {
sum += v[i]; //uninitialized using
}
printf("sum=%f\n", sum);
return 0;
}
gcc compiles it without any warning of uninitialized variable.
I'm using gcc 4.6.3 with following options:
gcc -Wall main.c -o main
What option should I use to get warning?