This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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








Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]