[LLVMbugs] [Bug 18216] New: [-cxx-abi microsoft] Layout involving pragma pack, declspec(align) and bitfields is wrong

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Dec 11 12:38:35 PST 2013


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

            Bug ID: 18216
           Summary: [-cxx-abi microsoft] Layout involving pragma pack,
                    declspec(align) and bitfields is wrong
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: david.majnemer at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

consider:
#if defined(__clang__) || defined(__GNUC__)
typedef __SIZE_TYPE__ size_t;
#endif
extern "C" int printf(const char *fmt, ...);
inline void *operator new(size_t, void *pv) {}
#pragma pack(push, 4)
struct __declspec(align(256)) ClassName0 {
  __declspec(align(512)) char : 3;
};
struct __declspec(align(2)) ClassName1 : public ClassName0 {
  ClassName1() {}
};
struct ClassName2 : public ClassName0, public ClassName1 {};
struct ClassName3 : public ClassName0, public ClassName1 {};
static void test_layout(const char *class_name, size_t size_of_class,
                        size_t align_of_class) {
  printf("   sizeof(%s): %Iu\n", class_name, size_of_class);
}
template <typename Class>
static void init_mem() {}
#define test(Class) \
  init_mem<Class>(), test_layout(#Class, sizeof(Class), __alignof(Class))
int main() { test(ClassName0); }

msvc:
   sizeof(ClassName0): 256

clang:
   sizeof(ClassName0): 512

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20131211/4acd5073/attachment.html>


More information about the llvm-bugs mailing list