[previous] 3401 [next] Possible precedence confusion: extra parentheses are recommended here.
Miscellaneous

The order in which operators are processed in this expression is not sufficiently clear and so additional parentheses are recommended. In the absence of parentheses, the sequence is determined by rules of precedence and associativity.

Message 3401 has been superseded by messages 3389,3391,3392,3394,3395,3396 and 3397. It is also generated when the operand of a * operator is a / operation or the operand of a / operator is a *.

For example:


/*PRQA S 584,2017,3103,3198,3199,3203,3393,3408,3447 ++*/

extern int a;
extern int b;
extern int c;

extern void foo(void)
{
    int r;

    r = a * b / c;                    /* Message 3401 */
    r = (a * b) / c;                  /* OK           */

    r = a / b * c;                    /* Message 3401 */
    r = (a / b) * c;                  /* OK           */

    r = a + b - c;                    /* OK           */
    r = (a + b) - c;                  /* OK           */

    r = a - b + c;                    /* OK           */
    r = (a - b) + c;                  /* OK           */

}



No MISRA-C:2004 Rules applicable to message 3401


QA·C Source Code Analyser 8.1
MISRA-C:2004 Compliance Module 3.2
© 2012 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index Contents