-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
llvm-gcc asserts on address of field in bit field structure #1792
Comments
Test case is in test/C++Frontend/2007-05-15-FieldAcces.cpp http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070514/049620.html |
From Duncan Sands: Duncan also reported this assertion: |
Test case for this problem. |
Also, when fixed, the testcase should go in llvm-test, not dejagnu. |
I can make the test case deja-gnu compatible (doesn't execute). I'll do this |
maybe Duncan has an idea about this one |
Here, the 32bit int field is used for 'c' and 's'. However it has enough bits (8) available for 'c2', so there is |
This compiles to something sensible looking with llvm-gcc-4.2. |
…2a8171454cf12a33e35e3ae6f9dc2+33eb64704292dc2fc8585b8aa7459f96482c6cf9 🍒/bastille/76e3a27c16d2a8171454cf12a33e35e3ae6f9dc2+33eb64704292dc2fc8585b8aa7459f96482c6cf9
Extended Description
The following transcript shows llvm-gcc failing on input that gcc 4.0.4 compiles
correctly.
[reid@bashful C++Frontend]$ cat 2007-05-15-FieldAccess.cpp
#include <stdio.h>
class bitFieldStruct {
public:
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@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@bashful C++Frontend]$ gcc -o doit 2007-05-15-FieldAccess.cpp -lstdc++
[reid@bashful C++Frontend]$ ./doit
sizeof(bitFieldStruct) == 8
Offset bitFieldStruct.i = 0
Offset bitFieldStruct.c2 = 7
The text was updated successfully, but these errors were encountered: