![]() |
![]() |
3446 | ![]() |
||||
![]() | |||||||
| Side Effects | |||||||
Evaluation of this conditional operator may induce side effects. Side effects occur when an expression:
#pragma PRQA_NO_SIDE_EFFECTS funcnameThe conditional operator is often a source of confusion. If side effects are involved, it may be wiser to use an if statement. For example:
/*PRQA S 3198,3199,3227,3396,3408,3440,3447 ++*/
extern int fn(void);
extern int r;
extern void foo(int a, int b)
{
r = ( a > 0 ) ? b : a++; /* Message 3446 */
r = ( a > 0 ) ? fn() : b; /* Message 3446 */
r = ( a++ > 0 ) ? b : (b + 1); /* Message 3416 */
}
See also:
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |