This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: unsigned comparison warning
- From: Ian Lance Taylor <iant at google dot com>
- To: Hariharan <hariharans at picochip dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 29 Jul 2008 07:10:55 -0700
- Subject: Re: unsigned comparison warning
- References: <488EE8E4.4050309@picochip.com>
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