[EMAIL PROTECTED] 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. _______________________________________________ fpc-devel maillist - [email protected] http://lists.freepascal.org/mailman/listinfo/fpc-devel
