Santiago A. wrote:
El 23/12/2015 a las 12:13, Dennis Poon escribió:
Did you call A.Create before calling TestDerived? Maybe A.List was not
initialized (which is done in constructor Create) and contains an
invalid pointer (to dynamic array of string).
When you call SetLength, it decrements the reference count of A.List
(which is not nil) and raisesSIGSEGV.
Dennis
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
It's an object, not a class inherited from Tobject, so it hasn't create
constructor.
Even if it is an object, you can still define a constructor.
A constructor should initialize the memory area of the object to 0, even
if you don't explicitly assign List := nil;
It is safer to call this constructor before you handle the List.
The fact that it raises SIGEGV in TestDervived but not in TestSimple
might just be a random luck in how the compiler handles the memory space
involved.
You should not rely on this behavior.
Dennis
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal