c++/168: Spurious warning in 2.95.2

Wolfgang Bangerth bangerth@ticam.utexas.edu
Tue Oct 22 15:01:00 GMT 2002

This is equally well a C report as a C++ report, since the problem appears 
with both languages. The questionably code is
int main () {
  unsigned char      uc;
  unsigned short int usi;
  unsigned int       ui;
  if (uc + usi >= ui);
and the report is that this issues an error
  t.i:5: warning: comparison between signed and unsigned

As Jason pointed out, this is due to the fact that the left hand side is 
converted to an integer. I have no opinion about the validity or the 
warning, people should use casts to avoid this. I just wanted to share the 
reduced code.

This may be something for value range propagation, since then it would be 
clear that the left hand side must be positive.


Wolfgang Bangerth              email:           bangerth@ticam.utexas.edu
                               www: http://www.ticam.utexas.edu/~bangerth

More information about the Gcc-bugs mailing list