* Inherit recordalignment by objects. Otherwise static instances of child objects are not aligned properly. Mantis #10454.

+ Test.

git-svn-id: trunk@9495 -
This commit is contained in:
yury 2007-12-21 15:35:32 +00:00
parent 1361239124
commit 6a4ee90cb0
2 changed files with 24 additions and 0 deletions

View File

@ -3907,6 +3907,8 @@ implementation
tObjectSymtable(symtable).datasize:=
tObjectSymtable(symtable).datasize+
tObjectSymtable(c.symtable).datasize;
{ inherit recordalignment }
tObjectSymtable(symtable).recordalignment:=tObjectSymtable(c.symtable).recordalignment;
if (oo_has_vmt in objectoptions) and
(oo_has_vmt in c.objectoptions) then
tObjectSymtable(symtable).datasize:=

22
tests/webtbs/tw10454.pp Normal file
View File

@ -0,0 +1,22 @@
{$mode objfpc}
type
TMyObject = object
Int: longint;
end;
TMyObject2 = object(TMyObject)
end;
TMyClass = class
FByte: byte;
Obj: TMyObject2; // instance of this object is not aligned
end;
var
myclass: TMyClass;
begin
myclass:=TMyClass.Create;
myclass.obj.int:=1; // Crash due to unaligned data access
myclass.Free;
end.