From a21f462a93624c6ca8f66a2cf29fa2d3d98724db Mon Sep 17 00:00:00 2001 From: florian Date: Fri, 16 Feb 2018 18:45:54 +0000 Subject: [PATCH] * references of fields for types using indirect addressing get proper alignment git-svn-id: trunk@38252 - --- compiler/ncgmem.pas | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/ncgmem.pas b/compiler/ncgmem.pas index 864fcc3221..4e2672729b 100644 --- a/compiler/ncgmem.pas +++ b/compiler/ncgmem.pas @@ -355,8 +355,10 @@ implementation if (not is_managed_type(left.resultdef)) or (target_info.system in systems_garbage_collected_managed_types) then begin - { the contents of a class are aligned to a sizeof(pointer) } - location_reset_ref(location,LOC_REFERENCE,def_cgsize(resultdef),voidpointertype.size,[]); + { take care of the alignment of the fields } + if not(left.resultdef is tabstractrecorddef) then + Internalerror(2018021601); + location_reset_ref(location,LOC_REFERENCE,def_cgsize(resultdef),newalignment(tabstractrecorddef(left.resultdef).alignment,vs.fieldoffset),[]); case left.location.loc of LOC_CREGISTER, LOC_REGISTER: