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]

g++ Warning Incorrect?


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

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