From a2426178dcdf97713e41bb8eb809a7f311c4c0ca Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Sat, 26 May 2012 14:14:59 +0000 Subject: [PATCH] * don't insert type conversions in add nodes if both arguments are constant and if the result does not depend on the types of the arguments (to prevent "qwordconst>int64const" being turned into "int64(qwordconst)>int64const" and thereby potentially change the outcome) (mantis #19622) git-svn-id: trunk@21395 - --- .gitattributes | 1 + compiler/nadd.pas | 10 ++++++++++ tests/webtbs/tw19622.pp | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 tests/webtbs/tw19622.pp diff --git a/.gitattributes b/.gitattributes index c017d72a18..671ca476cf 100644 --- a/.gitattributes +++ b/.gitattributes @@ -12498,6 +12498,7 @@ tests/webtbs/tw19500.pp svneol=native#text/pascal tests/webtbs/tw19511.pp svneol=native#text/pascal tests/webtbs/tw19548.pp svneol=native#text/pascal tests/webtbs/tw19555.pp svneol=native#text/pascal +tests/webtbs/tw19622.pp -text svneol=native#text/plain tests/webtbs/tw1964.pp svneol=native#text/plain tests/webtbs/tw19651.pp svneol=native#text/plain tests/webtbs/tw19700.pp svneol=native#text/plain diff --git a/compiler/nadd.pas b/compiler/nadd.pas index c51a645a92..a52dad90bc 100644 --- a/compiler/nadd.pas +++ b/compiler/nadd.pas @@ -1347,6 +1347,16 @@ implementation if (torddef(rd).ordtype<>scurrency) then inserttypeconv(right,s64currencytype); end + { leave some constant integer expressions alone in case the + resultdef of the integer types doesn't influence the outcome, + because the forced type conversions below can otherwise result + in unexpected results (such as high(qword)b; + if not c then + halt(1); + if not(qword($FFFFFFFFFFFFFFFF)>9223372036854775807) then + halt(2); + c:=qword($FFFFFFFFFFFFFFFF)>b; + if not c then + halt(3); + c:=18446744073709551615>=9223372036854775807; + if not c then + halt(4); + + + aa:=$FFFFFFFF; + bb:=2147483647; + c:=aa>bb; + if not c then + halt(5); + if not ($FFFFFFFF>2147483647) then + halt(6); + c:=$FFFFFFFF>bb; + if not c then + halt(7); + c:=4294967295>=2147483647; + if not c then + halt(8); +End.