c++/1056: spurious warning on implicit conversion followed by promotion and comparison
Wolfgang Bangerth
bangerth@ticam.utexas.edu
Sun Nov 10 13:16:00 GMT 2002
The following reply was made to PR c++/1056; it has been noted by GNATS.
From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: gcc-bugs@gcc.gnu.org, <gcc-gnats@gcc.gnu.org>
Cc:
Subject: Re: c++/1056: spurious warning on implicit conversion followed by
promotion and comparison
Date: Sun, 10 Nov 2002 15:16:47 -0600 (CST)
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
More information about the Gcc-prs
mailing list