[LLVMbugs] [Bug 19180] New: MS ABI: layout of class with vbptr and vfptr is wrong

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Mar 18 13:57:57 PDT 2014


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

            Bug ID: 19180
           Summary: MS ABI: layout of class with vbptr and vfptr 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:

extern "C" int printf(const char *, ...);
static char buffer[419430400];
inline void *operator new(size_t, void *pv) { return pv; }
struct A {
  char fiel;
  A() {
    printf("A(fiel): %d\n", &fiel - buffer);
  }
};
struct B {
  char fiel;
  B() {
    printf("B(fiel): %d\n", &fiel - buffer);
  }
  virtual void OverrideMethod() {}
};
struct C {
  char fiel;
  C() {
    printf("C(fiel): %d\n", &fiel - buffer);
  }
};
struct D : public A, public B, public virtual C {
  D() {
    printf("D(this): %d\n", (char *)this - buffer);
    printf("D(A   ): %d\n", (char *)(A *)this - buffer);
    printf("D(B   ): %d\n", (char *)(B *)this - buffer);
    printf("D(C   ): %d\n", (char *)(C *)this - buffer);
  }
};

int main() { new (buffer) D; }


MSVC gives:
C(fiel): 16
A(fiel): 12
B(fiel): 4
D(this): 0
D(A   ): 12
D(B   ): 0
D(C   ): 16

clang gives:
C(fiel): 20
A(fiel): 8
B(fiel): 4
D(this): 0
D(A   ): 8
D(B   ): 0
D(C   ): 20

-- 
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/20140318/683bb426/attachment.html>


More information about the llvm-bugs mailing list