[fpc-devel] Need patch for bugs : 0011503 / 0009472
jonas.maebe at elis.ugent.be
Thu Jun 19 13:39:01 CEST 2008
On 19 Jun 2008, at 13:21, Boian Mitov wrote:
> Thank you!
> I don't understand. 0011503 is a major failure. Is it in the
> compiler or in some library?
Please read the comments to http://bugs.freepascal.org/view.php?
id=9472. The whole issue is discussed there in great detail.
> This is a huge problem. This code must work the same way in both
> cases but it does not. We are porting a huge library of over 4
> million lines of code from Delphi. This is a major show stopper. I
> can probably take a look in the compiler as it will be much easier
> and faster for us to fix the compiler to be Delphi compatible rather
> than rewriting the libraries. They rely heavily on interfaces and
> the correct reference counting. Rewriting this even if desirable
> will delay the project with at least a year at best. By definition
> when there are no active references to an interface it must be
> released. This is a total failure of the functionality.
There are active references, namely in an invisible temp. When this
invisible temp is destroyed (at the function exit), the interface is
It is wrong to assume that implicit temps which still contain
references to interfaces (or ansistrings, or any other reference
counted type) can never exist, because this is an implementation
detail over which the compiler has full control. This can also happen
in Delphi under certain circumstances by the way (namely if it cannot
guarantee that optimising the interface assignment is safe without
using a temp).
The purpose of automatic reference counting is simply that memory
management is automated. It is not to guarantee the same semantics as
what you would get in a manual reference counting scheme where you are
in full control of when and where reference counts are increased and
decreased. In principle, a periodic mark and sweep would also still be
Newer versions of FPC optimise assignments of function results more
aggressively so you will more often get reference counting behaviour
like in Delphi, but we do not guarantee in any way that it will be
100% identical. We only emulate the Delphi language, not the
implementation details of the Delphi compiler or code generator.
More information about the fpc-devel