* fix for Mantis #38390: use Val instead of StrToInt to avoid overload problems

+ added test

git-svn-id: trunk@48399 -
This commit is contained in:
svenbarth 2021-01-24 14:57:20 +00:00
parent 268f7bfb5c
commit c3fd06b6b5
3 changed files with 29 additions and 1 deletions

1
.gitattributes vendored
View File

@ -18644,6 +18644,7 @@ tests/webtbs/tw3833.pp svneol=native#text/plain
tests/webtbs/tw38337.pp svneol=native#text/plain
tests/webtbs/tw38339.pp svneol=native#text/plain
tests/webtbs/tw38351.pp -text svneol=native#text/pascal
tests/webtbs/tw38390.pp svneol=native#text/pascal
tests/webtbs/tw3840.pp svneol=native#text/plain
tests/webtbs/tw3841.pp svneol=native#text/plain
tests/webtbs/tw3863.pp svneol=native#text/plain

View File

@ -1,8 +1,12 @@
Class Function TORDINALHELPER.Parse(const AString: string): TORDINALTYPE; inline; static;
var
Error: Integer;
begin
Result:=StrToInt(AString);
Val(AString,Result,Error);
if Error<>0 then
raise EConvertError.CreateFmt(SInvalidInteger,[AString]);
end;
Class Function TORDINALHELPER.Size: Integer; inline; static;

23
tests/webtbs/tw38390.pp Normal file
View File

@ -0,0 +1,23 @@
program tw38390;
{$MODE Delphi}
uses SysUtils;
var
s: String;
x: UInt64;
begin
s := '20000000000';
x := UInt64.Parse(s);
WriteLn(x);
if x <> 20000000000 then
Halt(1);
UInt64.TryParse(s, x);
WriteLn(x);
if x <> 20000000000 then
Halt(2);
x := StrToQWord(s);
WriteLn(x);
if x <> 20000000000 then
Halt(3);
end.