We have to reserve at least the width of a pointer for the vfptr. For
classes with small alignment, we weren't reserving enough space, and
were overlapping the first field with the vfptr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192626
91177308-0d34-0410-b5e6-
96231b3b80d8
// the max alignment of all the non-virtual data in the class. The resulting
// layout is essentially { vftbl, { nvdata } }. This is completely
// unnecessary, but we're not here to pass judgment.
- Size += Alignment;
updateAlignment(PointerAlignment);
+ Size += Alignment;
}
void
// CHECK: 5 | struct B1 (virtual base) (empty)
// CHECK: | [sizeof=8, align=4
// CHECK: | nvsize=4, nvalign=4]
-
+
+struct F { char a; virtual ~F(); };
+
+// CHECK: *** Dumping AST Record Layout
+// CHECK: 0 | struct F
+// CHECK: 0 | (F vftable pointer)
+// CHECK: 4 | char a
+// CHECK: | [sizeof=8, align=4
+// CHECK: | nvsize=8, nvalign=4]
+
int a[
sizeof(A)+
sizeof(B)+
sizeof(C)+
sizeof(D)+
-sizeof(E)];
+sizeof(E)+
+sizeof(F)];