Synopsis: | An if statement must not lead to a degenerate comparison, for example the comparison of an unsigned quantity against a negative-valued constant. |
Language: | C |
Severity Level: | 4 |
Category: | STATEMENTS |
Description: |
Some conditions will always be true or false dependent on the type that has been used. For instance, a signed char is never larger than 128 or an unsigned integer can never be negative (see the example below). Example: unsigned int z = 0; ... if (z < 0) /* 'z' can never be < 0 */ { ... } ... Any statements dependent on this test will never be executed. |