Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2009-03

FPC 2.2.4 rc1 Copy() function issue?

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Sooky Boo

I am using fpc 2.2.4 rc1 and I have a dynamic array of records which I Copy() to another variable, the copied array has reference pointers to the original array, I don't think this was the case in earlier versions of fpc.

Anyone know a work around? I could make a function the sets the lengths of the array and then sets each property of the record but the record definition sometimes changes and could lead to broken code.

Thanks

Reply by email

Sooky Boo
to Sooky Boo

Found a solution.
Copy() only works for one level deep and since using fpc 2.2.4 the array became two levels deep.

Solution copy array A to array B using copy, then for each element of array B copy nested array from A to B.

Reply by email

Thaddy
to Sooky Boo
Sooky Boo wrote 13 lines
Found a solution. Copy() only works for one level deep and since using fpc 2.2.4 the array became two levels deep. Solution copy array A to array B using copy, then for each element of array B copy nested array from A to B. ------------------------------------------------------------------------ _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

But that is not a bug: that is by design and is also the way Delphi (and other languages) should and do behave..
Only a record with simple types (incl. shortstrings) are fully copied with a move(). Not pointer dependencies.

Reply by email