<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-text-flowed" style="font-family: -moz-fixed;
      font-size: 14px;" lang="x-unicode">On 24.10.2017 23:18, Michael
      Van Canneyt via Lazarus wrote:
      <br>
      <blockquote type="cite" style="color: #000000;">
        On Tue, 24 Oct 2017, Giuliano Colla wrote:
        <br>
        <br>
        <blockquote type="cite" style="color: #000000;">Il 24/10/2017
          14:10, Michael Van Canneyt via Lazarus ha scritto:
          <br>
          <blockquote type="cite" style="color: #000000;">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.
            <br>
            <br>
            That the assignment is valid is Delphi compatible: only the
            procedure
            <br>
            address is copied. </blockquote>
          <br>
          I can confirm it as an fpc bug.
          <br>
        </blockquote>
        <br>
        No, I'm sorry to say that IMO you did not. I looked at your
        code.
        <br>
        <br>
        It simply works by accident in Delphi, because you are calling a
        method of the same object as the caller.
        <br>
      </blockquote>
      <br>
      Yes, the code is wrong. But the reason is that myMethod is
      assigned in FormCreate. The later "@myMethod := pMethod;"
      assignment overwrites only half of the myMethod:TProc variable and
      so correct Self stays in the second half of myMethod.
      <br>
      <br>
      Remove FormCreate and you get an AV.
      <br>
      <br>
      Furthermore, "Format('0x%P',[@Myself])" doesn't make sense - it
      should be "Format('0x%P',[Pointer(Myself)])".<br>
      <br>
      No bug at all - just wrong code.
      <br>
      <br>
      Ondrej
      <br>
    </div>
  </body>
</html>