[fpc-devel] Redefine FillChar() to use out parameter instead

Jonas Maebe jonas.maebe at elis.ugent.be
Tue Nov 17 15:19:10 CET 2009


On 17 Nov 2009, at 13:43, Thaddy <thaddy at thaddy.com> wrote:

> Jonas Maebe wrote:
>>
>> No, that is not possible. I once tried to change move and fillchar  
>> to use "out" parameters instead of "var" parameters, and the result  
>> was all sorts of crashes. The reason is that "out" has special  
>> semantics for reference counted types (they are finalized at the  
>> *caller* side), and move/fillchar are sometimes used to zero  
>> uninitialised data (so if the run time then tries to finalise  
>> garbage, you get crashes).
> In that case I suspect an implementation insect. The compiler/ 
> codegenerator should not differ between var and out, just the parser  
> should distinguish imho. A reference should never influence  
> "reference counting" and should surely not have anything to do with  
> finalisation at all, not even because copy on.  Most other languages  
> behave like that I think. What is the reason FPC differs?

Delphi compatibility. And Delphi does that because COM requires this  
behaviour.


Jonas



More information about the fpc-devel mailing list