Skip to main content

SA0055: Unnecessary comparisons of unsigned operands

Detects unnecessary comparisons with unsigned operands. An unsigned data type is never less than zero. This can be used as a sign check.

Justification: A comparison detected with this check yields a constant result and is an indication of an error in the code.

Importance: High

Example 65. Example
PROGRAM PLC_PRG
VAR
    byTest: BYTE;
END_VAR
// SA0055
WHILE byTest >= 0 DO
    byTest := byTest - 1;
END_WHILE

Output in the Messages view:

  • sa_icon_message.png SA0055: Unnecessary comparisons of unsigned operands