Skip to content
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

Closed
llvmbot opened this issue May 15, 2007 · 8 comments
Closed

llvm-gcc asserts on address of field in bit field structure #1792

llvmbot opened this issue May 15, 2007 · 8 comments
Labels
bugzilla Issues migrated from bugzilla compile-fail Use [accepts-invalid] and [rejects-valid] instead llvm-tools All llvm tools that do not have corresponding tag

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented May 15, 2007

Bugzilla Link 1420
Resolution FIXED
Resolved on Nov 19, 2007 11:01
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor

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

@llvmbot
Copy link
Collaborator Author

llvmbot commented May 15, 2007

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

@llvmbot
Copy link
Collaborator Author

llvmbot commented May 15, 2007

From Duncan Sands:
IMHO both assertions are symptoms of ConvertRECORD breakage.

Duncan also reported this assertion:
LLVM type size doesn't match GCC type size!
on a similar test case.

@llvmbot
Copy link
Collaborator Author

llvmbot commented May 15, 2007

Test case for this problem.
This is a deja-gnu ready test case, the same as in the initial comment on this
PR.

@lattner
Copy link
Collaborator

lattner commented May 15, 2007

Also, when fixed, the testcase should go in llvm-test, not dejagnu.

@llvmbot
Copy link
Collaborator Author

llvmbot commented May 16, 2007

I can make the test case deja-gnu compatible (doesn't execute). I'll do this
sometime soonish.

@lattner
Copy link
Collaborator

lattner commented May 23, 2007

maybe Duncan has an idea about this one

@llvmbot
Copy link
Collaborator Author

llvmbot commented May 23, 2007

Here, the 32bit int field is used for 'c' and 's'. However it has enough bits (8) available for 'c2', so there is
not any need to allocate another field.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Nov 19, 2007

This compiles to something sensible looking with llvm-gcc-4.2.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
troelsbjerre pushed a commit to troelsbjerre/llvm-project that referenced this issue Jan 10, 2024
…2a8171454cf12a33e35e3ae6f9dc2+33eb64704292dc2fc8585b8aa7459f96482c6cf9

🍒/bastille/76e3a27c16d2a8171454cf12a33e35e3ae6f9dc2+33eb64704292dc2fc8585b8aa7459f96482c6cf9
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla compile-fail Use [accepts-invalid] and [rejects-valid] instead llvm-tools All llvm tools that do not have corresponding tag
Projects
None yet
Development

No branches or pull requests

2 participants