http://llvm.org/bugs/show_bug.cgi?id=5591
Summary: Incorrect packed bitfields assignment
Product: new-bugs
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: new bugs
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected], [email protected],
[email protected]
Seems it's a bug. See below:
y...@yang-working:~$ clang -O1 -o small_1 small.c
y...@yang-working:~$ ./small_1
g_8.f0 = 0, g_8.f1 = 5, g_19.f0 = 0, g_19.f1 = 5
y...@yang-working:~$ clang -O2 -o small_2 small.c
y...@yang-working:~$ ./small_2
g_8.f0 = 0, g_8.f1 = 5, g_19.f0 = 0, g_19.f1 = 0
y...@yang-working:~$ cat small.c
#include <stdio.h>
#pragma pack(push)
#pragma pack(1)
struct S1 {
signed f0 : 10;
signed f1 : 10;
};
#pragma pack(pop)
struct S1 g_8 = {0,0};
struct S1 g_19 = {0,0};
static struct S1 func_2()
{
return g_8;
}
int main(void)
{
int l_16 = 0;
for (l_16 = 0; l_16 >= 0; l_16--)
{
g_8.f1 = g_8.f1 + 5;
g_19 = func_2();
}
printf("g_8.f0 = %d, g_8.f1 = %d, g_19.f0 = %d, g_19.f1 = %d\n", g_8.f0,
g_8.f1, g_19.f0, g_19.f1);
return 0;
}
y...@yang-working:~$ clang -v
clang version 1.1 (trunk 89559)
Target: i386-pc-linux-gnu
Thread model: posix
--
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs