G
glen herrmannsfeldt
In comp.lang.c Ian Collins said:Noob wrote:
(snip)
$ gcc -Wall -c tutu.c
tutu.c: In function 'foo':
tutu.c:4:3: warning: array subscript has type 'char' [-Wchar-subscripts]
tutu.c:4:3: warning: array subscript has type 'char' [-Wchar-subscripts]
tutu.c:4:3: warning: array subscript has type 'char' [-Wchar-subscripts]
Whatever the implementation of isdigit, why would a char subscript be
worthy of a diagnostic? Yes char is usually signed, but so are short,
int and long.
A signed char overflows to a negative value sooner.
Until not so many years ago, you would run past the end of memory
before an int subscript wrapped to negative values. Not so with
short of char.
Note that Java avoids this problem, as char is unsigned 16 bits,
all the other types in Java are signed.
-- glen