Browse Source

* fixed type of size parameter passed to fpc_getmem() when translating
new(pointer) (mantis #38054)

git-svn-id: trunk@47355 -

Jonas Maebe 4 years ago
parent
commit
091b0fde0c
3 changed files with 14 additions and 1 deletions
  1. 1 0
      .gitattributes
  2. 1 1
      compiler/pinline.pas
  3. 12 0
      tests/webtbs/tw38054.pp

+ 1 - 0
.gitattributes

@@ -18523,6 +18523,7 @@ tests/webtbs/tw38012.pp svneol=native#text/pascal
 tests/webtbs/tw38022.pp svneol=native#text/pascal
 tests/webtbs/tw3805.pp svneol=native#text/plain
 tests/webtbs/tw38051.pp svneol=native#text/pascal
+tests/webtbs/tw38054.pp svneol=native#text/plain
 tests/webtbs/tw3814.pp svneol=native#text/plain
 tests/webtbs/tw3827.pp svneol=native#text/plain
 tests/webtbs/tw3829.pp svneol=native#text/plain

+ 1 - 1
compiler/pinline.pas

@@ -382,7 +382,7 @@ implementation
 
                      { create call to fpc_getmem }
                      para := ccallparanode.create(cordconstnode.create
-                         (tpointerdef(p.resultdef).pointeddef.size,s32inttype,true),nil);
+                         (tpointerdef(p.resultdef).pointeddef.size,ptruinttype,true),nil);
                      addstatement(newstatement,cassignmentnode.create(
                          ctemprefnode.create(temp),
                          ccallnode.createintern('fpc_getmem',para)));

+ 12 - 0
tests/webtbs/tw38054.pp

@@ -0,0 +1,12 @@
+{ %norun }
+const
+   l = high(ptrint);	//   2000  <-->  2100
+type
+   t = array[ 1..l ]of int8;	//   1.95  <-->  2.05  GiBy
+var
+   p: ^t;
+begin
+   new(p);
+   writeln( sizeof(p^) );
+   p^[l]:=0;  writeln(p^[l])
+end .