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]

Re: unsigned comparison warning


Thanks Ian. I will raise this in gcc-help mailing list.

Cheers
Hari

Ian Lance Taylor wrote:
Hariharan <hariharans@picochip.com> writes:

I found something rather strange with the unsigned comparison warnings
in GCC.

This is the wrong mailing list. The mailing list gcc@gcc.gnu.org is for gcc developers. The mailing list gcc-help@gcc.gnu.org is for questions about using gcc. Please take any followups to gcc-help@gcc.gnu.org. Thanks.


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?

You neglected to mention the version of gcc. In current gcc, I don't see any warning when using "gcc -O2 -c trial.c". I see a warning for both "unsigned char" and "unsigned int" when I add the -Wextra option.

Ian


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