![]() |
![]() |
3415 | ![]() |
||||
![]() | |||||||
| Side Effects | REFERENCE - ISO:C90-5,1,2,3 Program Execution | ||||||
The right hand operand of a logical && operator is only evaluated if the left hand operand evaluates to 1 ("true"). The right hand operand of a logical || operator is only evaluated if the left hand operand evaluates to 0 ("false"). Because of this behaviour, confusion can arise if the right hand operand of either of these operators generates side effects. Message 3415 is generated to identify such a situation. Side effects occur when an expression:
#pragma PRQA_NO_SIDE_EFFECTS funcnameFor example:
/*PRQA S 2017,3199,3227,3398,3408,3440,3447 ++*/
extern int func1(void);
extern int func2(void);
#pragma PRQA_NO_SIDE_EFFECTS func2
extern void foo(int x, int y)
{
if ((x > 0) && (y++ < 0)) /* Messages 3415 and 3416 */
{
}
if ((x > 0) && func1()) /* Messages 3415 and 3416 */
{
}
if ((x > 0) && func2()) /* No message - no side effects */
{
}
}
See also:
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |