![]() |
![]() |
3440 | ![]() |
||||
![]() | |||||||
| Arithmetic type - Operations | REFERENCE - ISO:C90-6.3.2.4 Postfix Increment and Decrement Operators, ISO:C90-6.3.3.1 Prefix Increment and Decrement Operators | ||||||
The value resulting from a ++ or -- operation has been used. The ++ and -- operators are special in that they don't just return a value, they also generate side effects - by modifying their operand. If the result value is used, there are some particular dangers:
/*PRQA S 506,2017,3199,3203,3227,3408,3447 ++*/
extern void f1(int p);
extern void foo(int n, int *p)
{
int r;
++n; /* OK */
(*p)--; /* OK */
r = ++n; /* Message 3440 */
f1(r++); /* Message 3440 and 3441 */
}
MISRA C:2012 Rules applicable to message 3440:
| Rule-13.3 (Advisory) | A full expression containing an increment (++) or decrement (--) operator should have no other potential side effects other than that caused by the increment or decrement operator |
See also:
![]() | ||
| QA·C Source Code Analyser 8.1
MISRA C:2012 Compliance Module 1.0 © 2012 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index | Contents |