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

Giuliano Colla giuliano.colla at fastwebnet.it
Tue Oct 24 20:27:08 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 can confirm it as an fpc bug.

Delphi does apparently more than just copying the procedure address and 
dropping the data address. It doesn't raise an error, but it handles the 
assignment of a procedural type to a pointer in a sensible way.

The quickest way for me to test was using Kylix, so I created a minimal 
application to test the feature.

I created it in Kylix, then converted it to Lazarus.

Just two buttons and a memo.

Button1 displays the value of "Self" in the memo, and it is correct in 
both cases, Kylix and Lazarus.

Button2 makes an indirect call to a Method via a Pointer, always to 
display the "Self" value. It works in Kylix, it segfaults in Lazarus 
TForm1.Memo1Update, when executing Memo1.Lines.add(aString). But in 
Lazarus the debugger tells that the string it fails to display is "Self 
value is Nil".

Please find here enclosed the two sources of the test, the Delphi/Kylix 
one and the Lazarus one.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: lazarus.zip
Type: application/zip
Size: 2506 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20171024/dd8bc869/attachment-0002.zip>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kylix.zip
Type: application/zip
Size: 1488 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20171024/dd8bc869/attachment-0003.zip>

More information about the Lazarus mailing list