[fpc-devel] Problem with cascading Destructor in fpc 2.4
Michael Van Canneyt
michael at freepascal.org
Sat Oct 30 23:18:56 CEST 2010
On Sat, 30 Oct 2010, Martin Krüger wrote:
> Hi
>
> I introduced an boolean-option to the destructor of a class. I
> implemented a wrapper without argument for reason of
> backward-compability.
>
> This wrapper calls the real destructor with default argument.
>
> Everything worked fine until fpc 2.4 (sample programm below)
> When running it compiled with fpc 2.4 i get an Runtime error 216
> (segmentation fault).
> I could reproduce the problem with the latest svn head.
>
> Without further examination i suggest: The outer destructor tries to
> free the memory the inner destructor already released.
>
> So my question:
> Is it a bug or am i doing something i should not?
> The compiler gives me am note:
>
> test.pas(8,3) Note: Class should have one destructor only
This is your problem.
The destructor must always be called destroy (overriding TObject.Destroy)
and should accept no arguments. If you want to pass an argument to it somehow,
use a property which you set prior to calling destroy.
Michael.
More information about the fpc-devel
mailing list