[LLVMbugs] [Bug 1420] NEW: llvm-gcc asserts on address of field in bit field structure

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Mon May 14 23:48:31 PDT 2007


           Summary: llvm-gcc asserts on address of field in bit field
           Product: tools
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: llvm-gcc
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: rspencer at reidspencer.com

The following transcript shows llvm-gcc failing on input that gcc 4.0.4 compiles

[reid at bashful C++Frontend]$ cat 2007-05-15-FieldAccess.cpp
#include <stdio.h>

class bitFieldStruct {
    int i;
    unsigned char c:7;
    int s:17;
    char c2;

int main()
  printf("sizeof(bitFieldStruct) == %d\n", sizeof(bitFieldStruct));

  if (sizeof(bitFieldStruct) != 2 * sizeof(int))
    printf("bitFieldStruct should be %d but is %d \n",
            2 * sizeof(int), sizeof(bitFieldStruct));

  bitFieldStruct x;

  char* xip = (char*) &x.i;
  char* xc2p = (char*) &x.c2;
  printf("Offset bitFieldStruct.i = %d\n", xip - xip);
  printf("Offset bitFieldStruct.c2 = %d\n", xc2p - xip);

  return 0;
[reid at bashful C++Frontend]$ /proj/llvm/cfe/install-2/bin/llvm-gcc -o doit
2007-05-15-FieldAccess.cpp -lstdc++
cc1plus: ../../src-2/gcc/llvm-convert.cpp:5583: LValue
TreeToLLVM::EmitLV_COMPONENT_REF(tree_node*): Assertion `BitStart == 0 && "It's
a bitfield reference or we didn't get to the field!"' failed.
2007-05-15-FieldAccess.cpp: In function 'int main()':
2007-05-15-FieldAccess.cpp:18: internal compiler error: Aborted

[reid at bashful C++Frontend]$ gcc -o doit 2007-05-15-FieldAccess.cpp -lstdc++
[reid at bashful C++Frontend]$ ./doit
sizeof(bitFieldStruct) == 8
Offset bitFieldStruct.i = 0
Offset bitFieldStruct.c2 = 7

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

More information about the llvm-bugs mailing list