This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: g++ Warning Incorrect?
- From: <tm_gccmail at mail dot kloo dot net>
- To: Chip Cuntz <william dot c dot cuntz_iv at mci dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Fri, 29 Aug 2003 13:38:12 -0700 (PDT)
- Subject: Re: g++ Warning Incorrect?
On Fri, 29 Aug 2003, Chip Cuntz wrote:
This is a mailing list for the discussion of gcc and its internals, not
for help with programming in the C programming language.
You should ask these questions in the comp.lang.c Usenet newsgroup.
Toshi
> In the following function line 8 fails with compiler warning below. If I change the 0x00 to 0x01 it compiles without warning (but incorrect logic).
>
> Bug or ingnorance? Can someone provide the third eye here!
>
> ...
>
> 1 //
> 2 // Function: hex2chr();
> 3 //
> 4 char hex2chr( char chr )
> 5 {
> 6
> 7 if( chr >= 0x0A && chr <= 0x0F ) return chr += 0x37;
> 8 if( chr >= 0x00 && chr <= 0x09 ) return chr += 0x30;
> 9
> 10 return 0;
> 11
> 12 }
>
> From gvim:
>
> :!make 2>&1| tee /tmp/v207887/27
> ncidView.C: In function `char hex2chr(char)':
> ncidView.C:8: warning: comparison is always true due to limited range of data
> type
>
> GCC Version:
>
> Reading specs from /usr/local/lib/gcc-lib/rs6000-ibm-aix4.3.3.0/3.2.2/specs
> Configured with: configure --enable-languages=c,c++
> Thread model: aix
> gcc version 3.2.2