[fpc-pascal] Sigsegv with refcounting interface

Jonas Maebe jonas.maebe at elis.ugent.be
Sat Mar 9 12:33:32 CET 2013


On 09 Mar 2013, at 02:37, Joao Morais wrote:

> On Fri, Mar 8, 2013 at 4:09 PM, Flávio Etrusco <flavio.etrusco at gmail.com> wrote:
>> 
>>> procedure addintf(const aintf: IUnknown);
>>> (...)
>>>    addintf(TInterfacedObject.Create);
>>> (...)
>> 
>> It's a pity, but I don't know whether it's fixable (or if needs to be
>> "fixed") in the compiler.
> 
> Works in Delphi 7 with FastMM4.
[...]
> You are suggesting that this unlikely coincidente which causes a
> sigsegv should be the programmer's responsibility. No thanks, I much
> more prefer the Delphi compatibility =)

It indeed only works by accident in your Delphi code. It is just as wrong in Delphi as it is in FPC. It depends on an implementation detail of the code generator's reference counting. It's like saying that a particular piece of code in which an uninitialized local variable happens to be always 0 in Delphi should have the same behaviour in FPC. We don't aim for compatibility as far as providing the same behaviour for code of which the result is undefined.


Jonas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20130309/e5523d00/attachment.html>


More information about the fpc-pascal mailing list