Red Hat Bugzilla – Bug 7025
signed char == 0xa5 always 0 - why??
Last modified: 2008-05-01 11:37:52 EDT
egcs-2.91-66 generates the following warning on this code:
[root@chameleon Linux]# gcc -o foo foo.c
foo.c: In function `main':
foo.c:6: warning: comparison is always 0 due to limited range of data type
main(int argc, char **argv)
int rc = 0;
char c = 0xa5, *ptr=&c;
if (*ptr == 0xa5) rc = 1; /* This is the line that generates the warning
signed char ranges from -127 to 127 (or so).
Hence, a signed char cannot be 0xa5. An unsigned char could be.