The following test warns about the comparison being always true only for two of the six tests:
#include <cstdlib> void a (unsigned char x) { if (x < 0) abort (); } void b (unsigned short x) { if (x < 0) abort (); } void c (unsigned int x) { if (x < 0) abort (); } void d (unsigned long x) { if (x < 0) abort (); } void e (unsigned long long x) { if (x < 0) abort (); } void f (size_t x) { if (x < 0) abort (); } [EMAIL PROTECTED]:::~/tmp> g++ -save-temps -fverbose-asm -O3 -c test.cxx test.cxx: In function 'void a(unsigned char)': test.cxx:5: warning: comparison is always false due to limited range of data type test.cxx: In function 'void b(short unsigned int)': test.cxx:11: warning: comparison is always false due to limited range of data type [EMAIL PROTECTED]:::~/tmp> g++ -v Using built-in specs. Target: i386-unknown-freebsd4.10 Configured with: ../srcdir/configure --disable-nls --enable-version-specific-runtime-libs --enable-dwarf2 --with-cpu=pentium3 --with-arch=pentium3 --with-system-zlib --disable-shared --prefix=/home/4/wilx --enable-languages=c,c++,objc,ada --disable-sjlj-exceptions --enable-shared=libstdc++ --enable-shared=libobjc Thread model: posix gcc version 4.1.0 20050821 (experimental) -- Summary: Missing "warning: comparison is always false due to limited range of data type" Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: v dot haisman at sh dot cvut dot cz CC: gcc-bugs at gcc dot gnu dot org,v dot haisman at sh dot cvut dot cz GCC build triplet: i386-unknown-freebsd4.10 GCC host triplet: i386-unknown-freebsd4.10 GCC target triplet: i386-unknown-freebsd4.10 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23587