free quality report for PLCopenXML exports

Rules / array-write-overlap

Two programs write the same cells of an exchange array

The rule collects the cells each POU writes by literal index (including the width of pointer writes) and finds overlaps. A REAL written through a pointer takes two words, and another POU puts its own value into one of them.

Severity: Warning Rule id: array-write-overlap Two POUs write the same array cells

What the rule checks

A shared exchange array (HMI registers, Modbus, SCADA) is filled by several POUs, each with its own part. The rule collects the cells every POU writes by literal index and looks for overlaps between different POUs. The width of pointer writes is taken into account: if a function receives ADR(A[k]) in series with a step of 2, it writes two words and A[k+1] is taken too. Direct writes A[k] := from two POUs are not a finding on their own (that is often deliberate: initialisation versus operation, different modes), so a pointer write must be part of the overlap. The consequence: whichever runs later in the scan wins, the other POU's value never reaches the receiver, and the screen shows garbage instead of outputs or run times.

What it does to the plant

Whichever runs later wins: the value on the HMI or in SCADA flickers or shows someone else's data.

Example

Bad: the rule fires
VAR_GLOBAL    aPanel : ARRAY[0..63] OF WORD;    rT1, rT2, rT3 : REAL;    wState1, wState2 : WORD;END_VARFUNCTION PackReal : BOOLVAR_INPUT    rValue : REAL;    pDest : POINTER TO DWORD;END_VARpDest^ := REAL_TO_DWORD(rValue);PackReal := TRUE;PROGRAM PanelTempsPackReal(gvl.rT1, ADR(gvl.aPanel[20]));PackReal(gvl.rT2, ADR(gvl.aPanel[22]));PackReal(gvl.rT3, ADR(gvl.aPanel[24]));PROGRAM PanelStatesgvl.aPanel[21] := gvl.wState1;gvl.aPanel[30] := gvl.wState2;
Fixed: the rule is silent
VAR_GLOBAL    aPanel : ARRAY[0..63] OF WORD;    rT1, rT2, rT3 : REAL;    wState1, wState2 : WORD;END_VARFUNCTION PackReal : BOOLVAR_INPUT    rValue : REAL;    pDest : POINTER TO DWORD;END_VARpDest^ := REAL_TO_DWORD(rValue);PackReal := TRUE;PROGRAM PanelTempsPackReal(gvl.rT1, ADR(gvl.aPanel[20]));PackReal(gvl.rT2, ADR(gvl.aPanel[22]));PackReal(gvl.rT3, ADR(gvl.aPanel[24]));PROGRAM PanelStatesgvl.aPanel[29] := gvl.wState1;gvl.aPanel[30] := gvl.wState2;

Both listings are run through the linter by an automated test: the rule fires on the first and stays silent on the second.

How to fix

  1. Separate the addresses: every value in the exchange table needs its own cell, and a two-word value takes two.
  2. If two POUs really take turns writing the cell, keep a single writer and give the other one a flag or a separate variable.
Check your project

Upload a PLCopen XML or CODESYS .export file: the report is free and the code is not stored.

Local version on GitHub →

The same linter without uploading a file: command line and GitHub Action.

Related rules

2026-11-26

Processing happens in memory, and the uploaded code is not stored. The tool advises; code changes are up to the engineer (see what the linter can't see). What happens to your code → · Rule reference · Your code & privacy · Industry benchmark · Feedback · GitHub