[fpc-devel] Managed Types, Undefined Bhaviour

Mattias Gaertner nc-gaertnma at netcologne.de
Fri Jun 29 16:53:29 CEST 2018


On Fri, 29 Jun 2018 16:18:04 +0200 (CEST)
Michael Van Canneyt <michael at freepascal.org> wrote:

> On Fri, 29 Jun 2018, Michael Van Canneyt wrote:
> 
> >
> >
> > On Fri, 29 Jun 2018, Martok wrote:
> >  
> >> Am 29.06.2018 um 14:41 schrieb Michael Van Canneyt:  
> >>> As far as I can see, you get 2 chain and 1 done call. Which is what I'd   
> > expect.  
> >>> The overrides of the _* calls are useless, since they are not virtual in
> >>> TInterfacedObject and hence never called. So that's OK too.  
> >> Interface functions are always virtual and implemented by the actually
> >> instantiated class.  
> 
> > The "override" keyword is neither allowed nor needed, this  
> >> code does what it looks like.
> >>
> >> The expected output would be 3 Addrefs and 3 Releases.  
> >
> > I don't get that.  
> 
> Pressed send too quickly.
> 
> home:~> ./tirc   
> Chain: 00007FA5948CF040
> Chain: 00007FA5948CF040
> Done: 00007FA5948CF040

"stdcall" is wrong for Linux. It must be
{$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};

Then you get under Linux:
Addref: 00007F0B935BF040 Refcount: 1 at 000000000041331A
Addref: 00007F0B935BF040 Refcount: 2 at 00000000004121F2
Release: 00007F0B935BF040 Refcount: 2 at 0000000000412196
Chain: 00007F0B935BF040
Addref: 00007F0B935BF040 Refcount: 2 at 000000000041331A
Addref: 00007F0B935BF040 Refcount: 3 at 00000000004121F2
Release: 00007F0B935BF040 Refcount: 3 at 0000000000412196
Chain: 00007F0B935BF040
Addref: 00007F0B935BF040 Refcount: 3 at 000000000041331A
Addref: 00007F0B935BF040 Refcount: 4 at 00000000004121F2
Release: 00007F0B935BF040 Refcount: 4 at 0000000000412196
Done: 00007F0B935BF040
fin
Release: 00007F0B935BF040 Refcount: 3 at 0000000000412196
Release: 00007F0B935BF040 Refcount: 2 at 0000000000412196
Release: 00007F0B935BF040 Refcount: 1 at 0000000000412196

Mattias



More information about the fpc-devel mailing list