2
0
Эх сурвалжийг харах

* fixed compiler crash when using a bitpacked array whose size was
close to high(longint) bytes

git-svn-id: trunk@13241 -

Jonas Maebe 16 жил өмнө
parent
commit
e13a708002

+ 1 - 0
.gitattributes

@@ -8228,6 +8228,7 @@ tests/test/tparray22.pp svneol=native#text/plain
 tests/test/tparray23.pp svneol=native#text/plain
 tests/test/tparray24.pp svneol=native#text/plain
 tests/test/tparray25.pp svneol=native#text/plain
+tests/test/tparray26.pp svneol=native#text/plain
 tests/test/tparray3.pp svneol=native#text/plain
 tests/test/tparray4.pp svneol=native#text/plain
 tests/test/tparray5.pp svneol=native#text/plain

+ 3 - 3
compiler/symdef.pas

@@ -2376,10 +2376,10 @@ implementation
             exit;
           end;
 
+        result:=cachedelesize*aint(cachedelecount);
         if (ado_IsBitPacked in arrayoptions) then
-          size:=(cachedelesize * aint(cachedelecount) + 7) div 8
-        else
-          result:=cachedelesize*aint(cachedelecount);
+          { can't just add 7 and divide by 8, because that may overflow }
+          result:=result div 8 + ord((result mod 8)<>0);
       end;
 
 

+ 10 - 0
tests/test/tparray26.pp

@@ -0,0 +1,10 @@
+{ %norun }
+
+type
+  ta = bitpacked array[0..high(longint)-1] of 0..1;
+var
+  p: pointer;
+begin
+  getmem(p,sizeof(ta));
+  ta(p^)[high(longint)-1]:=1;
+end.