The reason I as this is the following: In DB.pas there is a method TFloatField.GetAsInteger.
It is implemented as follows:
function TFloatField.GetAsFloat: Double;
if not GetData(@Result) then Result := 0;
function TFloatField.GetAsInteger: Longint;
Result := Longint(Round(GetAsFloat));
Round returns a Int64 and the result is casted to Integer. My problem is that some developer in my team use AsInteger for numeric(11,0) fields (which delphi translated into TFloatField) and Delphi generates no error at all also when Range Checking is on and Overflow Checking is on ($R- is specified in db.pas). I even tried the following:
function GetAsFloat: Double;
Result := 4000000000000000000;
procedure TForm1.Button1Click(Sender: TObject);
But I never get an error.
My question is the following:
- Can I get an error in D5 for this problem (without rewriting or patching the VCL)
- If so how?
- If it is not possible how should this patching:
- By disabeling the AsInteger property for TFloatFields
- By checking in the GetAsFloat for values that do not fit
- What advice do you have when patching the VCL (we want to be able to use a new version of Delphi without to much repatching the new VCL version)