[fpc-devel] Problem with cascading Destructor in fpc 2.4
Martin Krüger
martin.krueger at gmx.com
Sat Oct 30 17:54:13 CEST 2010
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
--
Best regards,
Martin
------------
program cascading_destructor;
type
test=class
constructor create();
destructor destroy();overload;
destructor destroy(arg:boolean);overload;
end;
constructor test.create();
begin
end;
destructor test.destroy();
begin
writeln('calling master destroy');
destroy(true);
writeln('master destroy done');
end;
destructor test.destroy(arg:boolean);
begin
writeln('destroyed');
end;
var a:test;
begin
a:=test.create();
a.destroy;
end.
type
test=class
constructor create();
destructor destroy();overload;
destructor destroy(arg:boolean);overload;
end;
constructor test.create();
begin
end;
destructor test.destroy();
begin
writeln('calling master destroy');
destroy(true);
writeln('master destroy done');
end;
destructor test.destroy(arg:boolean);
begin
writeln('destroyed');
end;
var a:test;
begin
a:=test.create();
a.destroy;
end.
More information about the fpc-devel
mailing list