[previous] 2994 [next] The value of this 'while' or 'for' loop controlling expression is always 'false'. The loop will not be entered.
Invariant operations

The value of the controlling expression in this 'while' or 'for' statement is always zero. The code within the loop is therefore unreachable.

For example:


/*PRQA S 2017,3120,3199,3201,3227,3356,3359,3408,3447 ++*/

extern int y;

void f1(int x)
{
    int i;
    
    if (x < 10)
    {
        for (i = 20; i < x; ++i)        /* 2994 2996 */
        {
            ++y;                        /* 2880      */
        }
    }
}

See also:

QA·C Source Code Analyser 8.1.2
© 2013 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index Contents