Răsfoiți Sursa

* calc_divconst_magic_unsigned: explicitly limit the shift amount to number of bits of target platform. This happens implicitly only on x86, on other 32-bit targets shifting by more than 31 bits calculates as zero.

git-svn-id: trunk@27983 -
sergei 11 ani în urmă
părinte
comite
d6c6c84f76
1 a modificat fișierele cu 1 adăugiri și 1 ștergeri
  1. 1 1
      compiler/cgutils.pas

+ 1 - 1
compiler/cgutils.pas

@@ -388,7 +388,7 @@ uses
         magic_add:=false;
 {$push}
 {$warnings off }
-        mask:=aWord(not 0) shr (64-N);
+        mask:=aWord(not 0) shr ((64-N) and (sizeof(aWord)*8-1));
         nc:=(mask-(-d) mod aInt(d));
 {$pop}
         p:=N-1;                       { initialize p }