> On Jun 10, 2019, at 3:25 PM, Ben Grasset <[email protected]> wrote:
>
> Result in your example is the size of a pointer in all cases, which is fine /
> exactly what you'd expect it to be.
>
Sorry, if I dereference the size is still of TBase. I don’t think “result" is
actually changing depending on the class type. This may have something to do
with the way new works though. How can we fix this?
type
PBase = ^TBase;
TBase = object
constructor Initialize;
class function Create: PBase; static;
end;
class function TBase.Create: PBase;
begin
new(result, Initialize);
writeln('create: ', sizeof(result^));
end;
constructor TBase.Initialize;
begin
writeln('create tfoo')
end;
type
PChild = ^TChild;
TChild = object (TBase)
y: string;
end;
var
c: PChild;
begin
c := PChild(TChild.Create);
Regards,
Ryan Joseph
_______________________________________________
fpc-devel maillist - [email protected]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel