C++ Templates and "comparison of unsigned expression < 0 is always false"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All,

I usually compile with -Wall -Wextra -Wno-deprecated -Wno-unused. The
options do a very good job, but I still get some noise from template
code:

template< class T >
SomeClass<T>::SomeFunc(const T& t)
{
   // warning: comparison of unsigned expression < 0 is always false
   if(t < 0)
   {
       ...
   }
}

Does anyone have any tricks to remove the warning for the case that
type T is unsigned*? Or is there a "brief" switch so I can cut the
warning down to one line from the following (cryptopp/misc.h:414 and
the warning is all I really need).

cryptopp/misc.h: In function ‘std::string CryptoPP::IntToString(T,
unsigned int) [with T = long unsigned int]’:
cryptopp/simple.h:35:   instantiated from here
cryptopp/misc.h:414: warning: comparison of unsigned expression < 0 is
always false

Jeff

* I don't agree with Linus and his proclamation that "GCC is crap". I
took a compiler theory class in college, and know its going to be
difficult to produce a better GCC. ("[PATCH] Don't compare unsigned
variable for <0 in sys_prctl()",
http://www.mail-archive.com/linux-kernel@xxxxxxxxxxxxxxx/msg99150.html)



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux