Skip to main content

SA0019: Implicit pointer conversions

Detects implicitly generated pointer conversions

Justification: In CODESYS, pointers are not strictly typed and they can be assigned to each other in any way. This is often used and therefore not reported by the compiler. However, it can also lead to unauthorized and unexpected access. For example, if you assign the type POINTER TO DWORD to a pointer with the type POINTER TO BYTE, memory can be overwritten in an unwanted way.

Therefore, always check this rule and block the message only in cases where you intentionally want to access a value with a different type.

Conversions to and from the POINTER TO BYTE data type are not checked by the SA0019 rule. They are always allowed.

Implicit data type conversions are reported with a different message.

Importance: High

PLCopen rule: CP25

Exception: BOOL <-> BIT

Example 54. Example
PROGRAM PLC_PRG
VAR
    pInt : POINTER TO INT;
    byteVar : BYTE;
END_VAR
pInt := ADR(byteVar);

Output in the Messages view:

  • sa_icon_message.png SA0019: Implicit conversion from pointer to 'POINTER TO BYTE' to pointer to 'POINTER TO INT'