[fpc-devel] sizeof member in class procedure

Sven Barth pascaldragon at googlemail.com
Thu Aug 16 10:30:27 CEST 2018


Am 15.08.2018 um 00:30 schrieb Benito van der Zander:
> Hi,
>
> why is sizeof on object/class fields sometimes allowed and sometimes not?
>
> type TTest = object
>   f: integer;
>   class procedure test;
> end;
>
> class procedure TTest.test;
> begin
>   writeln(sizeof(f));             // does not compile
>   writeln(sizeof(TTest.f));  // compiles
> end;
>
> ---
>
> type TTest = class
>   f: integer;
>   class procedure test;
> end;
>
> class procedure TTest.test;
> begin
>   writeln(sizeof(f));             // does not compile
>   writeln(sizeof(TTest.f));  // does not compile
> end;
>
> surely that should all be equal to sizeof(integer)
Interestingly Delphi does not allow it either (though it fails with two 
different errors for the two variants (note: I only tested the class 
one)), so its behavior is the same as in FPC there. I personally would 
say that it should be allowed however... *shrugs*

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20180816/dced242d/attachment.html>


More information about the fpc-devel mailing list