Skip to main content

SA0028: Overlapping memory areas

Detects the lines of code where two or more variables reserve the same memory.

Justification: When two variables reserve the same memory, the code may behave with unexpected results. This situation should be avoided at all costs. If you cannot avoid using a value in different interpretations (for example, one time as DINT and another time as REAL), then you should define a UNION. You can also use a pointer to access a value with a different type without the value being converted.

Importance: High

Example 40. Example
PROGRAM PLC_PRG
VAR
    iVvar1 AT %QB21: INT;
    dwVar2 AT %QD5: DWORD;
END_VAR

Output in the Messages view:

  • sa_icon_message.png The following variables access the same memory:

  • sa_icon_message.png SA0028: iVar1 AT %QB21

  • sa_icon_message.png SA0028: dwVar2 AT %QD5



For more information, see: