[LLVMbugs] [Bug 18720] New: No conversion warning for assigning 1 to a bit-field of type "int:1"

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Feb 3 23:01:25 PST 2014


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

            Bug ID: 18720
           Summary: No conversion warning for assigning 1 to a bit-field
                    of type "int:1"
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: chengniansun at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

I have a bit-field "int f:1;", and Clang does not warn if I assign 1 to it,
i.e., "c.f = 1;" 


$: cat bitfield-signed-char.c
#include<stdio.h>
struct C {int f:1;};
int main() {
  struct C c;
  c.f = 1;
  printf("c.f = %d\n", c.f);
  c.f = 1;
  printf("c.f = %d\n", c.f);
  return 0;
}
$: clang-trunk -std=c11 -Weverything bitfield-signed-char.c
bitfield-signed-char.c:2:8: warning: padding size of 'struct C' with 31 bits to
alignment boundary [-Wpadded]
struct C {int f:1;};
       ^
1 warning generated.
$: ./a.out
c.f = -1
c.f = -1
$

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140204/bbcca7ab/attachment.html>


More information about the llvm-bugs mailing list