From c3fd06b6b5986d7a1db7971cd0633d8b2421615b Mon Sep 17 00:00:00 2001 From: svenbarth Date: Sun, 24 Jan 2021 14:57:20 +0000 Subject: [PATCH] * fix for Mantis #38390: use Val instead of StrToInt to avoid overload problems + added test git-svn-id: trunk@48399 - --- .gitattributes | 1 + rtl/objpas/sysutils/syshelpo.inc | 6 +++++- tests/webtbs/tw38390.pp | 23 +++++++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 tests/webtbs/tw38390.pp diff --git a/.gitattributes b/.gitattributes index af9cc586b0..b466c1a519 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/rtl/objpas/sysutils/syshelpo.inc b/rtl/objpas/sysutils/syshelpo.inc index 0ab24ea753..2f6efc6994 100644 --- a/rtl/objpas/sysutils/syshelpo.inc +++ b/rtl/objpas/sysutils/syshelpo.inc @@ -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; diff --git a/tests/webtbs/tw38390.pp b/tests/webtbs/tw38390.pp new file mode 100644 index 0000000000..11a2c523b0 --- /dev/null +++ b/tests/webtbs/tw38390.pp @@ -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.