This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/168: Spurious warning in 2.95.2
- From: Wolfgang Bangerth <bangerth at ticam dot utexas dot edu>
- To: gcc-bugs at gcc dot gnu dot org, <gcc-gnats at gcc dot gnu dot org>, <martin at loewis dot home dot cs dot tu-berlin dot de>, <tmwg-gcc at inxservices dot com>
- Date: Tue, 22 Oct 2002 16:48:33 -0500 (CDT)
- Subject: 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