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

            Bug ID: 18021
           Summary: [-cxx-abi microsoft] Clang lays class out wrong when
                    most derived class has a bitfield
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

consider:
#include <stddef.h>
#include <stdio.h>
#include <string.h>
char buffer[419430400];
inline void *operator new(size_t, void *pv) { return pv; }
struct ClassName00 {
        long long ClassName00FieldName00;
        ClassName00() {
                printf("ClassName00FieldName00 : %llu\n", (unsigned long
long)((size_t)&ClassName00FieldName00 - (size_t)buffer));
        }
};
struct ClassName02: public virtual ClassName00 {
        long long ClassName02FieldName00;
        ClassName02() {
                printf("ClassName02FieldName00 : %llu\n", (unsigned long
long)((size_t)&ClassName02FieldName00 - (size_t)buffer));
        }
};
struct ClassName03: public virtual ClassName02 {
        int ClassName03FieldName3 : 1;
        ClassName03() {
        }
};
int main() {
        memset(buffer, 0, sizeof(buffer));
        new (buffer) ClassName03;
        printf("   sizeof(ClassName03): %Iu\n",    sizeof(ClassName03));
        printf("__alignof(ClassName03): %Iu\n", __alignof(ClassName03));
        memset(buffer, 0, sizeof(buffer));
}


clang gives us:
ClassName00FieldName00 : 16
ClassName02FieldName00 : 32
   sizeof(ClassName03): 40
__alignof(ClassName03): 8

MSVC gives us:
ClassName00FieldName00 : 16
ClassName02FieldName00 : 40
   sizeof(ClassName03): 48
__alignof(ClassName03): 8

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

Reply via email to