![]() |
![]() |
3394 | ![]() |
||||
![]() | |||||||
| Readability | |||||||
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. In this expression, there are 2 different shift operators, 2 different relational operators or 2 different equality operators. The 2 operators have the same precedence and so the first operator (the left hand one) is evaluated first. Add parentheses to make this clear. For example:
/*PRQA S 502,2017,3198,3199,3203,3401,3408,3447,4112,4131 ++*/
extern int a;
extern int b;
extern int c;
extern void foo(void)
{
int r;
r = a << b >> c; /* Message 3394 +3390 */
r = (a << b) >> c; /* OK */
r = a < b > c; /* Message 3394 +3390 */
r = (a < b) > c; /* OK */
r = a == b != c; /* Message 3394 +3390 */
r = (a == b) != c; /* OK */
}
See also:
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |