[cfe-dev] -Wsign-compare warns on different signs of operands for ?:

Richard Trieu rtrieu at google.com
Wed Jul 13 17:15:13 PDT 2011


For code such as:

void f(unsigned int u, int i) {
  (void) (true ? u : i);
}

When run with -Wsign-compare, Clang gives the following warning.

warning: operands of ? are integers of different signs:
      'unsigned int' and 'int' [-Wsign-compare]
  (void) (true ? u : i);
               ^ ~   ~

Yet, no comparison is going on between u and i, so the warning seems out of
place for grouping with -Wsign-compare.  I think that it would be better is
this warning was pulled out of the -Wsign-compare diagnostic group.  Also,
gcc's -Wsign-compare does not warn on this code, so this change will make
Clang's sign compare closer to gcc's.  Does this seem reasonable?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110713/bbd18d72/attachment.html>


More information about the cfe-dev mailing list