On Sat, Mar 9, 2013 at 8:33 AM, Jonas Maebe <jonas.ma...@elis.ugent.be> wrote: > > On 09 Mar 2013, at 02:37, Joao Morais wrote: >> >> On Fri, Mar 8, 2013 at 4:09 PM, Flávio Etrusco <flavio.etru...@gmail.com> >> wrote: >>> >>> [...] >>> >> >> 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.
I see your point and this helped me find what's helping delphi work by accident, thanks for that. It's nice to see that the code bellow also fails when compiled with delphi. =) > We don't aim for compatibility as far as providing the same behaviour > for code of which the result is undefined. I fully agree with you: code which results in an undefined behavior is a programmer's responsibility. I was talking about some refcounting management which doesn't exist. It's clear now that this scenario is like memory leak because of circular references: another issue of refcounted objects. Anyway I'd like to see some fixes in the rtl, not because of compatibility but because of performance improvement: not declaring refcounted parameters such as ansi strings and com interfaces will lead to useless calls to incref and decref. Should I open a bug report for this improvement for some popular classes (ie this may be changed in thunk)? Joao Morais ===================== program project1; {$ifdef fpc}{$mode objfpc}{$H+}{$endif} // declare "breakcode" to break the code =) {.$define breakcode} uses {$ifdef fpc}heaptrc{$else}fastmm4{$endif}, sysutils, Classes; {$ifndef fpc} type PtrUInt = longint; {$endif} procedure stuff({$ifndef breakcode}const{$endif} v: IUnknown); begin writeln('current: ', PtrUInt(v)); end; var vintfl: TInterfaceList; procedure addintf(const aintf: IUnknown); begin writeln('calling stuff...'); stuff(aintf); writeln('calling indexOf'); if vintfl.IndexOf(aintf) = -1 then begin writeln('adding to intflist...'); vintfl.Add(aintf); end; end; begin vintfl := TInterfaceList.Create; try writeln('starting...'); addintf(TInterfacedObject.Create); writeln('success!'); finally FreeAndNil(vintfl); end; end. _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal