[LLVMbugs] [Bug 5591] New: Incorrect packed bitfields assignment

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Sun Nov 22 16:07:07 PST 2009


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: unassignedbugs at nondot.org
        ReportedBy: chenyang at cs.utah.edu
                CC: llvmbugs at cs.uiuc.edu, regehr at cs.utah.edu,
                    jxyang at cs.utah.edu


Seems it's a bug. See below:

yang at yang-working:~$ clang -O1 -o small_1 small.c
yang at yang-working:~$ ./small_1
g_8.f0 = 0, g_8.f1 = 5, g_19.f0 = 0, g_19.f1 = 5
yang at yang-working:~$ clang -O2 -o small_2 small.c
yang at yang-working:~$ ./small_2
g_8.f0 = 0, g_8.f1 = 5, g_19.f0 = 0, g_19.f1 = 0
yang at 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;
}
yang at 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.



More information about the llvm-bugs mailing list