This is the mail archive of the gcc-help@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]

-Wextra with unsigned template parameters


Hi, I'm using -Wextra (-W) to compile my code, one
feature of which is throwing a warning when an
unsigned type is checked for >= 0 since it's always
true.  In general I find this to be very helpful, but
it throws this error even for templates which may have
instantiations with signed types elsewhere.  A code
example is included below.  Does anyone know how best
to supress this warning without removing the condition
or turning off -Wextra?  Thank you in advance.

template <typename T>
struct foo {    
  foo(T bar) { if (bar >= 0) bar = 1; }
};

foo<unsigned> baz(3);

When this code is compiled by gcc 3.3 with -W -c, it
warns that the comparison of unsigned expression >= 0
is always true.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


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