Просмотр исходного кода

* 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 лет назад
Родитель
Сommit
d6c6c84f76
1 измененных файлов с 1 добавлено и 1 удалено
  1. 1 1
      compiler/cgutils.pas

+ 1 - 1
compiler/cgutils.pas

@@ -388,7 +388,7 @@ uses
         magic_add:=false;
         magic_add:=false;
 {$push}
 {$push}
 {$warnings off }
 {$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));
         nc:=(mask-(-d) mod aInt(d));
 {$pop}
 {$pop}
         p:=N-1;                       { initialize p }
         p:=N-1;                       { initialize p }