[LLVMbugs] [Bug 10929] New: inconsistent warning for implicit truncation to bitfield

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Sep 14 21:37:37 PDT 2011


           Summary: inconsistent warning for implicit truncation to
           Product: clang
           Version: trunk
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: neal.meyer at riverbed.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com

Using the following code

const int FLAG = 0x4;
int FLAG2 = 0x4;

struct {
    u_int32_t flags_  :  3; // REFS / NOT_INSERTED / FRESH
} bits_;

int main (int argc, char * const argv[]) {

    bool flag = (bits_.flags_ &= ~(FLAG));
    flag = (bits_.flags_ &= ~(FLAG2));

Only the const int produces the following warning:

/main.cpp:501:31:{501:34-501:41}: warning: implicit truncation from 'int' to
bitfield changes value from -5 to 3 [-Wconstant-conversion,3]
     bool flag = (bits_.flags_ &= ~(FLAG));
                               ^  ~~~~~~~
1 warning generated.

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.

More information about the llvm-bugs mailing list