SA0059: Comparison operations always returning TRUE or FALSE
Function | Determines comparisons with literals whose result is always TRUE or FALSE and which can already be evaluated during compilation. |
Reason | An operation that consistently returns TRUE or FALSE is an indication of a programming error. |
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_VARbResult := nBYTE <= 255; // => SA0059
bResult := nBYTE <= BYTE#255; // => SA0059
bResult := nWORD <= WORD#65535; // => SA0059
bResult := nDWORD <= DWORD#4294967295; // => SA0059
bResult := nLWORD <= LWORD#18446744073709551615; // => SA0059
bResult := nUSINT <= USINT#255; // => SA0059
bResult := nUINT <= UINT#65535; // => SA0059
bResult := nUDINT <= UDINT#4294967295; // => SA0059
bResult := nULINT <= ULINT#18446744073709551615; // => SA0059
bResult := nSINT >= -128; // => SA0059
bResult := nSINT >= SINT#-128; // => SA0059
bResult := nINT >= INT#-32768; // => SA0059
bResult := nDINT >= DINT#-2147483648; // => SA0059
bResult := nLINT >= LINT#-9223372036854775808; // => SA0059