[LLVMbugs] [Bug 10819] New: #pragma pack for template structs ignored

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Aug 31 04:22:30 PDT 2011


http://llvm.org/bugs/show_bug.cgi?id=10819

           Summary: #pragma pack for template structs ignored
           Product: clang
           Version: 2.9
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: muhineg at gmail.com
                CC: llvmbugs at cs.uiuc.edu


#pragma pack ignored for template structures. Tested on clang 2.9 on mac and
win32. Code:

#include <cstdio>

#pragma pack(1)

struct A
{
  int a;
  char b;
  int c;
};

template <class T>
struct B
{
  T a;
  char b;
  T c;
};

int main ()
{
  printf ("sizeof A = %u\n", sizeof (A));
  printf ("sizeof B<int> = %u\n", sizeof (B<int>));

  return 0;
}


Prints:
sizeof A = 9
sizeof B<int> = 12
Should print:
sizeof A = 9
sizeof B<int> = 9

-- 
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