This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/1056: spurious warning on implicit conversion followed bypromotion and comparison
- 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>
- Date: Sun, 10 Nov 2002 15:16:47 -0600 (CST)
- Subject: Re: c++/1056: spurious warning on implicit conversion followed bypromotion and comparison
This report is about this code:
---------------------------------------
struct X {
operator unsigned short () const;
};
int main() {
X s;
unsigned long l;
if (l == s);
if (s == l);
return 0;
}
------------------------------
and the following warnings:
tmp/g> /home/bangerth/bin/gcc-3.3x-pre/bin/gcc -W -Wall -c x.cc
x.cc: In function `int main()':
x.cc:9: warning: comparison between signed and unsigned integer expressions
x.cc:10: warning: comparison between signed and unsigned integer expressions
I had initially thought that this may be due to argument promotion to a
signed type from the unsigned short the conversion operator returns, but
then the same should happen when we define "s" as an unsigned short right
from the start. However, this makes the warning go away. So I don't
know...
W.
-------------------------------------------------------------------------
Wolfgang Bangerth email: bangerth@ticam.utexas.edu
www: http://www.ticam.utexas.edu/~bangerth