[previous] 3441 [next] Function call argument is an expression with possible side effects.
Side Effects REFERENCE - ISO:C90-5.1.2.3 Program Execution, ISO:C90-6.3.2.2 Function Calls - Semantics

The evaluation of this function argument may generate side effects.

Side effects occur when an expression:

However QAC assumes that side effects occur whenever a function is called, unless the function has specifically been identified as being free from side effects by a #pragma statement of the form:
#pragma PRQA_NO_SIDE_EFFECTS funcname

The presence of side effects in function call arguments may be dangerous if there is more than one argument, because the order in which the arguments are evaluated is unspecified. Even if the order of evaluation is not significant, the presence of side effects in the context of a function argument will add to the complexity of the code.

For example:


/*PRQA S 506,3210,3226,3408,3440,3442,3447,3602 ++*/

#pragma PRQA_NO_SIDE_EFFECTS f3

extern void f1(int a);
extern int  f2(void);
extern int  f3(void);
extern void f4(int a, int b);

extern int            n;
extern volatile int * pv;

extern void foo(void)
{
    f1(n);
    f1(n++);                /* Message 3441 */
    f1(*pv);                /* Message 3441 */
    f1(n = 1);              /* Message 3441 */
    f1(f2());               /* Message 3441 */
    f1(f3());               /* No message ! */

    f4(++n, ++n);           /* Message 3441 + 0400 - dangerous */
}


No MISRA C:2012 Rules applicable to message 3441


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