PArray's size should take alignment into account.

This commit is contained in:
Randy Heit 2013-08-08 22:20:16 -05:00
parent 6c1f3a1396
commit 93cbdd37a5
2 changed files with 5 additions and 1 deletions

View file

@ -638,7 +638,10 @@ PArray::PArray(PType *etype, unsigned int ecount)
: ElementType(etype), ElementCount(ecount)
{
Align = etype->Align;
Size = etype->Size * ecount;
// Since we are concatenating elements together, the element size should
// also be padded to the nearest alignment.
ElementSize = (etype->Size + (etype->Align - 1)) & ~(etype->Align - 1);
Size = ElementSize * ecount;
}
//==========================================================================

View file

@ -355,6 +355,7 @@ public:
PType *ElementType;
unsigned int ElementCount;
unsigned int ElementSize;
virtual bool IsMatch(intptr_t id1, intptr_t id2) const;
virtual void GetTypeIDs(intptr_t &id1, intptr_t &id2) const;