Explorar el Código

* fixed constant evaluation check for negvalue+posvalue (mantis #11216)

git-svn-id: trunk@10808 -
Jonas Maebe hace 17 años
padre
commit
2413d4b43f
Se han modificado 3 ficheros con 23 adiciones y 1 borrados
  1. 1 0
      .gitattributes
  2. 1 1
      compiler/constexp.pas
  3. 21 0
      tests/webtbs/tw11216.pp

+ 1 - 0
.gitattributes

@@ -8144,6 +8144,7 @@ tests/webtbs/tw1111.pp svneol=native#text/plain
 tests/webtbs/tw11139.pp svneol=native#text/plain
 tests/webtbs/tw11169.pp svneol=native#text/plain
 tests/webtbs/tw1117.pp svneol=native#text/plain
+tests/webtbs/tw11216.pp svneol=native#text/plain
 tests/webtbs/tw1122.pp svneol=native#text/plain
 tests/webtbs/tw1123.pp svneol=native#text/plain
 tests/webtbs/tw1124.pp svneol=native#text/plain

+ 1 - 1
compiler/constexp.pas

@@ -160,7 +160,7 @@ begin
   {Try if the result fits in an int64.}
   if (a.signed) and (a.svalue<0) then
     {$Q-}
-    sspace:=qword(high(int64))-qword(-a.svalue)
+    sspace:=qword(high(int64))+qword(-a.svalue)
     {$ifdef ena_q}{$Q+}{$endif}
   else if not a.signed and (a.uvalue>qword(high(int64))) then
     goto try_qword

+ 21 - 0
tests/webtbs/tw11216.pp

@@ -0,0 +1,21 @@
+program TestRC;
+{$R+}
+
+var Li, Lj : Int64;
+const I = $7fffffffffffffff;
+
+begin
+  if (1-I)<>(-I+1) then
+    halt(1);
+
+  writeln(1-I);
+  writeln(-I+1);
+
+  Li := 1-I;
+  Lj := -I + 1;
+  if Li<>Lj then
+    halt(2);
+
+  if (Li<>-9223372036854775806) then
+    halt(3);
+end.