[previous] 0400 [next] [U] '%s' is modified more than once between sequence points - evaluation order unspecified.
Explicitly undefined REFERENCE - ISO:C90-6.3 Expressions

An object is being modified more than once between sequence points and the result will be undefined.

In C the order in which side effects are performed is not well defined. If an object is modified more than once between two sequence points, the C language does not define in which order the 2 updates are performed. Message 0400 is generated when an object is definitely modified more than once between sequence points. Definite sources of modification occur in assignment operations and increment and decrement operations.

In the example below, the expression on the right hand side of the assignment operation will evaluate to 10. The statement requires that "x" shoud be modified twice; once with an increment operation and once by assignment. Unfortunately, the C language does not specify which of these updating operations should be performed first. A compiler may choose to assign the value 10 and then increment it to the value 11. Alternatively, it may choose to increment the value of x to 3 and then update it by assignment to the value 10.


/*PRQA S 2017,3120,3199,3204,3227,3408,3440 ++*/

extern void foo(void)
{
    int x = 2;
    int y = 5;

    x = y * x++;        /* Message 400 */
}


MISRA-C:2004 Rules applicable to message 0400:

Rule  1.2  (Required) No reliance shall be placed on undefined or unspecified behaviour.
Rule  12.2  (Required) The value of an expression shall be the same under any order of evaluation that the standard permits.


See also:

QA·C Source Code Analyser 8.1
MISRA-C:2004 Compliance Module 3.2
© 2012 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index Contents