gcc
компилятор игнорирует uninitialized variable warning
для отладочной сборки. Это выглядит очень странно для меня, может кто-нибудь помочь мне понять это?
## Program
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int i, max;
int count;
if (argc < 2) {
return -1;
}
max = atoi(argv[1]);
for (i = 0; i < max; i++) {
count++;
}
printf("count is %d\n", count);
return 0;
}
g cc a. c -g -Wall -Werror
Нет предупреждения
g cc a. c -O3 -Wall -Werror
a.c: In function ‘main’:
a.c:8:9: error: ‘count’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
int count;
^~~~~
cc1: all warnings being treated as errors
gcc
версия: 7.4.0