Browse Source

* if a pointer_to_array type conversion is applied to a variable, it is not written, resolves #39957

florian 2 years ago
parent
commit
1c86a4bbeb
2 changed files with 11 additions and 1 deletions
  1. 2 1
      compiler/ncnv.pas
  2. 9 0
      tests/webtbs/tw39957.pp

+ 2 - 1
compiler/ncnv.pas

@@ -3775,7 +3775,8 @@ implementation
 
     procedure Ttypeconvnode.mark_write;
       begin
-        left.mark_write;
+        if not(convtype=tc_pointer_2_array) then
+          left.mark_write;
       end;
 
     function ttypeconvnode.first_cord_to_pointer : tnode;

+ 9 - 0
tests/webtbs/tw39957.pp

@@ -0,0 +1,9 @@
+{ %opt=-O4 -Oodeadstore -Oonoregvar }
+var
+	src: array[0 .. 9] of int32;
+	srcp: pInt32;
+
+begin
+	srcp := pInt32(src);
+	srcp[0] := 1;
+end.