after upgrading xe8 of our projects start break data. looks bug in tlist realization.
program xe8bug1; {$apptype console} uses system.sysutils, generics.collections; type trecord = record a: integer; b: int64; end; var frecord: trecord; flist: tlist<trecord>; begin flist := tlist<trecord>.create; frecord.a := 1; flist.insert(0, frecord); frecord.a := 3; flist.insert(1, frecord); frecord.a := 2; flist.insert(1, frecord); writeln(inttostr(flist[0].a) + inttostr(flist[1].a) + inttostr(flist[2].a)); end.
this code prints "123" in xe7 , before (as should be), in xe8 prints "120". maybe know quickfix this?
update: unofficial fix here
i found tlist<t>.insert
method call tlisthelper.internalinsertx
depends on data size, in case:
procedure tlisthelper.internalinsertn(aindex: integer; const value); var elemsize: integer; begin checkinsertrange(aindex); internalgrowcheck(fcount + 1); elemsize := elsize; if aindex <> fcount move(pbyte(fitems^)[aindex * elemsize], pbyte(fitems^)[(aindex * elemsize) + 1], (fcount - aindex) * elemsize); move(value, pbyte(fitems^)[aindex * elemsize], elemsize); inc(fcount); fnotify(value, cnadded); end;
i see problem in first move
call. destination should be:
pbyte(fitems^)[(aindex + 1) * elemsize]
not
pbyte(fitems^)[(aindex * elemsize) + 1]
aaargh!
finally, i've used system.generics.defaults.pas , system.generics.collections.pas units delphi xe7 in projects, , works expected.
update: see, rtl not affected, isn't use tlist<t>.insert
t sizeof > 8 (or maybe miss something?)