Something has changed with System.Str in Delphi XE2. The following procedure :
procedure someProcedure;
var
E:double;
outString:string;
begin
E:=-1.7E+308;
Str(E:i:j, outString);
end;
Raises an access violation
(exception class $C0000005, access violation at 0x00407318: read of address 0x30303028)
in Delphi XE2 where ‘i’ and ‘j’ are whatever integers. This same code works fine in Delphi 2010 and returns outString = ‘-1.7E+0308’. Similar code is used in a few of the TurboPower Orpheus components and it causes the entire IDE to crash on a BEX error.
This is in Win7 64-bit. Any ideas?
Edit : extra info
This seems to happen only with large negative numbers. Str seems to generate long strings which break when they exceed ~130 characters.
Note : this does not break when using only width (where i = some width)
procedure someProcedure;
var
E:double;
outString:string;
begin
E:=-1.7E+308;
Str(E:i, outString);
end;
It’s clearly a bug with the handling of large magnitude negative numbers. Positive numbers are handled fine. If you can intercept the calls to
Strthen you could make sure that you only ever callStrpassing positive numbers and then prefix the-yourself.I have submitted the bug to Quality Central: QC#103436.