From 1c86a4bbebf6bce1f14f2e3e17ab132fb3ccb8db Mon Sep 17 00:00:00 2001 From: florian Date: Fri, 14 Oct 2022 23:11:08 +0200 Subject: [PATCH] * if a pointer_to_array type conversion is applied to a variable, it is not written, resolves #39957 --- compiler/ncnv.pas | 3 ++- tests/webtbs/tw39957.pp | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 tests/webtbs/tw39957.pp diff --git a/compiler/ncnv.pas b/compiler/ncnv.pas index 7f33891c27..a6d63538a9 100644 --- a/compiler/ncnv.pas +++ b/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; diff --git a/tests/webtbs/tw39957.pp b/tests/webtbs/tw39957.pp new file mode 100644 index 0000000000..863180ddac --- /dev/null +++ b/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.