Forráskód Böngészése

* avoid internalerror for dec/inc(...,v) with v>high(int64), resolves #35298

git-svn-id: trunk@44031 -
florian 5 éve
szülő
commit
6c71fd461d
3 módosított fájl, 20 hozzáadás és 1 törlés
  1. 1 0
      .gitattributes
  2. 3 1
      compiler/ncginl.pas
  3. 16 0
      tests/webtbs/tw35298.pp

+ 1 - 0
.gitattributes

@@ -17904,6 +17904,7 @@ tests/webtbs/tw3523.pp svneol=native#text/plain
 tests/webtbs/tw35233.pp svneol=native#text/plain
 tests/webtbs/tw35272.pp svneol=native#text/plain
 tests/webtbs/tw3529.pp svneol=native#text/plain
+tests/webtbs/tw35298.pp svneol=native#text/pascal
 tests/webtbs/tw3531.pp svneol=native#text/plain
 tests/webtbs/tw3533.pp svneol=native#text/plain
 tests/webtbs/tw3534.pp svneol=native#text/plain

+ 3 - 1
compiler/ncginl.pas

@@ -451,7 +451,9 @@ implementation
             begin
 {$if not defined(cpu64bitalu) and not defined(cpuhighleveltarget)}
               if def_cgsize(left.resultdef) in [OS_64,OS_S64] then
-                cg64.a_op64_const_loc(current_asmdata.CurrAsmList,addsubop[inlinenumber],def_cgsize(left.resultdef),addvalue,tcallparanode(left).left.location)
+                { use addvalue.svalue here to avoid an internal error if addvalue is unsigned and overflows int64, see #35298,
+                  we are only interested in the bit pattern here }
+                cg64.a_op64_const_loc(current_asmdata.CurrAsmList,addsubop[inlinenumber],def_cgsize(left.resultdef),addvalue.svalue,tcallparanode(left).left.location)
               else
 {$endif not cpu64bitalu and not cpuhighleveltarget}
                 hlcg.a_op_const_loc(current_asmdata.CurrAsmList,addsubop[inlinenumber],left.resultdef,

+ 16 - 0
tests/webtbs/tw35298.pp

@@ -0,0 +1,16 @@
+{$MODE DELPHI}
+{$RANGECHECKS OFF}
+{$OVERFLOWCHECKS OFF}
+
+function SplitMix64(var X: UInt64) : UInt64;
+var
+  Z: UInt64;
+begin
+  Inc(X, UInt64($9E3779B97F4A7C15));
+  Z := (X xor (X shr 30)) * UInt64($BF58476D1CE4E5B9);
+  Z := (Z xor (Z shr 27)) * UInt64($94D049BB133111EB);
+  Result := Z xor (Z shr 31);
+end;
+
+begin
+end.