This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
unsigned comparison warning
- From: Hariharan <hariharans at picochip dot com>
- To: gcc at gcc dot gnu dot org, Hariharan Sandanagobalane <hariharans at picochip dot com>
- Date: Tue, 29 Jul 2008 10:54:44 +0100
- Subject: unsigned comparison warning
Hello,
I found something rather strange with the unsigned comparison warnings
in GCC.
If i had,
unsigned char
a;
int foo
()
{
if (a >=
0)
return
0;
else
return
1;
}
and i did gcc -O2 -c trial.c, then i get a warning
trial.c:6: warning: comparison is always true due to limited range of data type
It works the same way if i used an unsigned short. But, if i use unsigned int/long, i dont get this warning. This is on x86. Is there an explanation for this?
Cheers
Hari