[fpc-devel] Variant compiling errors
Florian Klaempfl
florian at freepascal.org
Thu Oct 13 10:32:14 CEST 2005
petr.kristan at epos.cz wrote:
> On Mon, Oct 10, 2005 at 02:11:04PM +0200, Florian Klaempfl wrote:
>
>>petr.kristan at epos.cz wrote:
>>
>>
>>>Hi.
>>>
>>>After a few hours with gdb was isolated errors and strangeness in compiler
>>>at work with variants:
>>>
>>>Example:
>>>
>>>function c(const vv: variant): variant;
>>>begin
>>> result := vv;
>>>end;
>>>
>>>function b(vv: variant): variant;
>>>begin
>>> result := vv;
>>>end;
>>>
>>>function a(var vv: variant): variant;
>>>begin
>>> result := vv;
>>>end;
>>>
>>>procedure start;
>>>var
>>> v, v1: Variant;
>>>begin
>>> v := VarArrayCreate([0, 0], varVariant);
>>>
>>> a(v);
>>> //if variant result of a() isn't assigned, fpc_finalize() at end of a(v)
>>> //destroys temporary result. But when start() ends fpc_finalize() tryes
>>> //to destroy it again
>>>
>>> b(v);
>>> //if b() is called then variant param is copied but not whole (deeply), vv.varray
>>> //points to the same place as v.array. At end of b(v) is pointer
>>> //vv.array destroyed by fpc_decref() and then v.array points to the
>>> //destroyed memory
>>>
>>> c(v);
>>> //At the start of func c() is v copied to the vv deeply but i think
>>> //that behaviour of "var" and "const" calling should be the same (by
>>> //reference) not vy value like c()
>>>end;
>>>
>>>I try to understand compiler code and repair it, but this is "very long
>>>distance race". But like I see the responses to my previous reports
>>>(absolutely no interest), this will be fastest solution :(. Really here
>>>isn't anybody who understand to compiler code and help me with repair?
>>>Or is anywhere another e-mail list or another comunication channel where
>>>i can talk about this problem?
>>>
>>>Petr
>>>
>>
>>The var arrays problems are known, see also
>>http://www.freepascal.org/bugs/showrec.php3?ID=3830
>>
>>It requires some design changes though that's why it isn't fixed yet. The
>>problem is that the compiler handles variants as ref. counted types when passing
>>them as parameters etc. However, this is wrong behaviour as soon as a variant
>>contains an array.
>
> Thanks for explanation. Yesterday i looked at compiler code and fpc
> internals documentation. I must recognize that fixing this is beyond my
> strength. Is somebody working on it? I can help with debugging.
> Vararray problem stopped my work -- porting big information system to fpc.
> In Rtl/fcl i can repair or fill missing, but here i'am helpless.
> For that reason i hurry on fixing this.
If you implement a fpc_copy procedure which copies rtti'ed types properly in
rtl/inc/rtti.inc, we're already a huge step forward :)
More information about the fpc-devel
mailing list