when I use char array subscript as in this example:
int main(){
char pos=0;
int array[100]={};
for(pos=0;pos<100;pos++)
printf("%i\n", array[pos]);
return 0;
}
I am getting warning that I am using char array subscript:
warning: array subscript has type ‘char’ [-Wchar-subscripts]
Which is OK, because I have this warning enabled.
GCC manual says:
-Wchar-subscripts Warn if an array subscript has type "char". This is a common cause of error, as programmers often forget that this type is signed on some machines. This warning is enabled by -Wall.
So this warning should prevent of using negative array index. My question is, why is this warning active only on char and not also on other signed types?
Thank you.