Browse Source

* fixed alignment of bitpacked arrays of ordinals/enums: the prevous code
always returned the alignment of enum/ordinal by itself, which could be
either bigger or smaller than what was required
* for non-bitpacked regular arrays, always use the alignment of the elements
instead of sometimes the natural alignment of the size of the elements
(which can be different)

git-svn-id: trunk@26019 -

Jonas Maebe 11 years ago
parent
commit
c1cec52897
1 changed files with 5 additions and 8 deletions
  1. 5 8
      compiler/symdef.pas

+ 5 - 8
compiler/symdef.pas

@@ -3427,16 +3427,13 @@ implementation
          { alignment of dyn. arrays doesn't depend on the element size }
          if (ado_IsDynamicArray in arrayoptions) then
            alignment:=size_2_align(sizeof(pint))
+         { alignment is the target alignment for the used load size }
+         else if (ado_IsBitPacked in arrayoptions) and
+            (elementdef.typ in [enumdef,orddef]) then
+           alignment:=cgsize_orddef(int_cgsize(packedbitsloadsize(elepackedbitsize))).alignment
          { alignment is the alignment of the elements }
-         else if (elementdef.typ in [arraydef,recorddef,orddef,enumdef,floatdef]) or
-           ((elementdef.typ=objectdef) and
-             is_object(elementdef)) then
-           alignment:=elementdef.alignment
-         { alignment is the size of the elements }
-         else if not (ado_IsBitPacked in arrayoptions) then
-           alignment:=size_2_align(elesize)
          else
-           alignment:=packedbitsloadsize(elepackedbitsize);
+           alignment:=elementdef.alignment
       end;