Explorar o código

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

florian %!s(int64=2) %!d(string=hai) anos
pai
achega
1c86a4bbeb
Modificáronse 2 ficheiros con 11 adicións e 1 borrados
  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.