Hello,
I have the following code
program FPCcast;
type
TMyClass1 = class
end;
TMyClass2 = class(TMyClass1);
var
O: TMyClass1;
begin
O := TMyClass1.Create;
TMyClass2(O).Free; // << 219-runtime error if compiled with -CR
end.If I compile it with "-CR", I get a 219-runtime error when casting O to TMyClass2. Is this wanted/documented? I see that {$OBJECTCHECKS OFF} fixes it.
The documentation seems not to give any information about cast check: http://www.freepascal.org/docs-html/3.0.0/prog/progsu57.html#x64-630001.2.57 http://www.freepascal.org/docs-html/3.0.0/user/userap1.html "Verify object method call validity" is not exact description -> the Free method is available both in TMyClass1 and TMyClass2, so I don't expect a runtime error here.
Why I ask: this hack is used in the LCL to access protected methods - i.e. the LCL doesn't work correctly with -CR.
Ondrej
