SA0055: Unnecessary comparison operations of unsigned operands

Function

Determines unnecessary comparisons with unsigned operands. An unsigned data type is never less than zero.

Reason

A comparison revealed by this check provides a constant result and indicates an error in the code.

Importance

High

Samples:

PROGRAM MAIN
VAR
    nBYTE   : BYTE;
    nWORD   : WORD;
    nDWORD  : DWORD;
    nLWORD  : LWORD;
    nUSINT  : USINT;
    nUINT   : UINT;
    nUDINT  : UDINT;
    nULINT  : ULINT;
 
    nSINT   : SINT;
    nINT    : INT;
    nDINT   : DINT;
    nLINT   : LINT;
 
    bResult : BOOL;
END_VAR
bResult := (nBYTE >= BYTE#0);    // => SA0055 
bResult := (nWORD < WORD#0);     // => SA0055
bResult := (nDWORD >= DWORD#0);  // => SA0055
bResult := (nLWORD < LWORD#0);   // => SA0055
bResult := (nUSINT >= USINT#0);  // => SA0055
bResult := (nUINT < UINT#0);     // => SA0055
bResult := (nUDINT >= UDINT#0);  // => SA0055
bResult := (nULINT < ULINT#0);   // => SA0055
 
bResult := (nSINT < SINT#0);     // no error
bResult := (nINT < INT#0);       // no error
bResult := (nDINT < DINT#0);     // no error
bResult := (nLINT < LINT#0);     // no error