[Lazarus] Weird object variables access [SOLVED] - Delphi mode bug!

Giuliano Colla giuliano.colla at fastwebnet.it
Tue Oct 24 14:56:12 CEST 2017


Il 24/10/2017 14:10, Michael Van Canneyt via Lazarus ha scritto:
> A valid method can never be stored in a pointer, since the former is 
> actually 2 pointers (method/data) and the latter is just 1 pointer.
>
> That the assignment is valid is Delphi compatible: only the procedure
> address is copied.

I wonder if Delphi does such a stupid thing, or rather it stores in the 
pointer the address of a pointer pair (method/data).
However here the issue is that a pointer can be assigned to a "procedure 
of object" without flagging an error:

type
   TProc = Procedure of object;
......
   NextProc: TProc;
....
     @NextProc := Coda.Remove; // Remove returns a pointer
     Sending := True;
     NextProc;

This compiles (in Delphi mode) without generating an error, and it is 
wrong, because NextProc is a Method, not a simple procedure.

Giuliano



More information about the Lazarus mailing list