From a89a4d905f1a93e0c022d3a8de35f655eadf4291 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Sun, 20 Nov 2016 11:44:25 +0000 Subject: [PATCH] + test for already fixed mantis #30948 git-svn-id: trunk@34928 - --- .gitattributes | 1 + tests/webtbs/tw30948.pp | 47 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 tests/webtbs/tw30948.pp diff --git a/.gitattributes b/.gitattributes index d52890dee4..0231bff1c5 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15264,6 +15264,7 @@ tests/webtbs/tw30936.pp svneol=native#text/pascal tests/webtbs/tw30936a.pp svneol=native#text/pascal tests/webtbs/tw30936b.pp svneol=native#text/pascal tests/webtbs/tw30936c.pp svneol=native#text/pascal +tests/webtbs/tw30948.pp svneol=native#text/plain tests/webtbs/tw3101.pp svneol=native#text/plain tests/webtbs/tw3104.pp svneol=native#text/plain tests/webtbs/tw3109.pp svneol=native#text/plain diff --git a/tests/webtbs/tw30948.pp b/tests/webtbs/tw30948.pp new file mode 100644 index 0000000000..933f5174d3 --- /dev/null +++ b/tests/webtbs/tw30948.pp @@ -0,0 +1,47 @@ +{$mode objfpc} +program BugInline; + +uses + sysutils; + +procedure Add64x2(HA,LA,HB,LB: QWord; out HR,LR: QWord); inline; +begin + Inc(LA,LB); + LR := LA; + HR := HA + HB + Ord(LA < LB); +end; + +procedure test; + var XHA, XLA, XLB, HA1, LA1, LB1, HA2, LA2, LB2 : QWord; +begin + XHA := QWord((Random($100000000) shl 32) or Random($100000000)); + XLA := QWord((Random($100000000) shl 32) or Random($100000000)); + XLB := QWord((Random($100000000) shl 32) or Random($100000000)); + + // the bug appears only when the sum "XLA + XLB" produces a carry + XLA := XLA or QWord($8000000000000000); + XLB := XLB or QWord($8000000000000000); + + HA1 := XHA; + LA1 := XLA; + LB1 := XLB; + Add64x2(HA1,LA1,0,LB1,HA1,LA1); + Writeln('LA1:HA1 = $' + IntToHex(LA1,16) + ':$' + IntToHex(HA1,16)); // OK + + HA2 := XHA; + LA2 := XLA; + LB2 := XLB; + Add64x2(HA2,LB2,0,LA2,HA2,LA2); + Writeln('LA2:HA2 = $' + IntToHex(LA2,16) + ':$' + IntToHex(HA2,16)); // wrong + + if HA1 <> HA2 then + begin + Writeln('HA1 and HA2 are not equal!'); + halt(1); + end; +end; + +begin + test; +end. +