http://llvm.org/bugs/show_bug.cgi?id=11274

             Bug #: 11274
           Summary: Missing warning for -Wconversion with compound
                    assignment
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]
    Classification: Unclassified


A warning is not generated for the compound assignment case, though it is for
standard operation + assignment.

Simple test case:

int main() {
    uint8_t a = 1;
    a <<= 1;     // missing warning

    uint8_t b = 1;
    b = b << 1;  // warns correctly
}

Generates a warning only for b, but not for a:

conv.c:9:6: warning: implicit conversion loses integer precision: 'int' to
'uint8_t'
      (aka 'unsigned char') [-Wconversion]
        b = b << 1;
          ~ ^~~~~~

gcc v4.5 gets this right:

conv.c:6:2: warning: conversion to ‘uint8_t’ from ‘int’ may alter its value
conv.c:9:2: warning: conversion to ‘uint8_t’ from ‘int’ may alter its value


By my reading of 6.5.16.2 Compound assignment, the two should be consistent.
  For the other operators, each operand shall have arithmetic type consistent
with those
allowed by the corresponding binary operator.


--

First bug report of any kind to llvm, I believe I've followed preferred style /
info, please let me know if otherwise.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to