C++ regression: comparing unsigned against integer literal

Gerald Pfeifer gerald@pfeifer.com
Thu Jul 10 14:50:00 GMT 2003


I'm having a hard time with my daily builds and regression tests lately,
and here is another, fresh issue: Given the following program

  extern unsigned u;

  int g() { return u > 1; }

  template<class F>
  int f() { return u > 1; }

gccvs y.cc -Wall warns about the second comparison (in the template
function) but does not warn for the regular function:

  y.cc: In function `int f()':
  y.cc:6: warning: comparison between signed and unsigned integer expressions

GCC used to warn in neither case, and I think that's highly preferrable
for constants in the range [0..INT_MAX].

Gerald



More information about the Gcc mailing list