On Thu, Jul 14, 2011 at 3:53 PM, Chandler Carruth <[email protected]>wrote:

> On Thu, Jul 14, 2011 at 3:35 PM, Richard Trieu <[email protected]> wrote:
>
>> Currently, -Wsign-compare will warn if conditional operands differ in
>> signedness. This patch will move this warning to -Wmixed-sign-conditional
>
>
> Why not -Wsign-conversion ? Just wondering why we need a separate flag
> here.
>
-Wsign-conversion has a separate warning that will override this one.
 Essentially, the conditional statement can have only have one type, so if
the operands are of different signs, one will be forced to convert, which
throws the warning.  Here's an example:

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

clang -Wsign-conversion
warning: operand of ? changes signedness: 'int' to 'unsigned int'
      [-Wsign-conversion]
  (void) (true ? u : i);
               ~     ^

clang -Wmixed-sign-conditional
warning: operands of ? are integers of different signs:
      'unsigned int' and 'int' [-Wmixed-sign-conditional]
  (void) (true ? u : i);
               ^ ~   ~
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to