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

Re: c++/168: Spurious warning in 2.95.2


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.

Regards
  Wolfgang

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



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