[fpc-pascal] Typecast class-of to class

Marco van de Voort marcov at stack.nl
Sun Feb 19 02:54:32 CET 2017

In our previous episode, Mattias Gaertner said:
> FPC allows to type cast a class-of variable to a class instance. Is
> this a bug or a feature?
> var
>   c: TClass;
> begin
>   TObject(c).ClassName; // crash
> end.

Feature (allowed because equal in size), used in e.g. Registerxxx functions to add class references to the
.objects part of tstringlist. Delphi has no container type for references

More information about the fpc-pascal mailing list