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++/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



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