I’m porting an old project to Delphi XE and I receive this warning on the code bellow.
function RemoveThousandSeperator(Text: String) : String;
Var P : Integer;
begin
if length(Text) > 3 then begin
p := Pos(FormatSettings.ThousandSeparator,Text);
while p >0 do begin
Delete(Text,p,1);
p := Pos(FormatSettings.ThousandSeparator,Text);
end;
end;
result := Text;
end;
even FormatSettings.ThousandSeparator is of type char.
LE: I am asking if someone can tell me why this warning occurs. The code is old and it will be remade.
LE2 : In order to get this warning all the warnings needs to be set to true in the Delphi Compiler-Hints & Warnings
LE3: If someone needs it – {$WARN UNSAFE_CAST OFF} makes the warning go off.
LE4: a screenshot of the warning for those who believe that the warning is hard to believe

The origin of the warning is declaration of
FormatSettingsvariable inSysUtils.pas:which casts string (
CurrencyString) to record (TFormatSettings).So the problem that generates the warning is in
SysUtils.pas, not in the code you posted,though the warning is generated in your code.
Here is a test case (Delphi XE):