[previous] 0403 [next] [U] '%s' may be modified and accessed between sequence points - evaluation order unspecified.
Explicitly undefined REFERENCE - ISO:C90-6.3 Expressions

It is possible that an object is being both modified and accessed between sequence points. The ISO:C Standard says that if an object is modified and accessed other than to determine the new value between sequence points, the result will be undefined.

If the value of an object is being used and the value is also being modified within a statement, it is important to know whether the modification will occur before or after its value is used. Unfortunately this is not always defined.

Message 0403 is generated when the ordering of an access to an object and a possible modification of the object are undefined. Possible sources of modification are associated with situations where the address of the object is passed to a function and the function parameter is not defined as a "pointer to a const qualified" type. In such situations, QAC is unable to determine whether the called function will actually modify the object or not; the function argument is simply identified as a possible source of modification.

In the code examples shown below:


/*PRQA S 2017,3120,3198,3199,3203,3227,3408,3440,3447,3602 ++*/

extern int psef(int *p);
extern int nsef(const int *p);
extern int x;

extern void foo(void)
{
    int r;

    r = x++ + (x * 2);                            /* a) - Message 402 */

    r = psef(&x) + (x * 2);                       /* b) - Message 403 */

    r = nsef(&x) + x;                             /* c)               */
}


MISRA-C:2004 Rules applicable to message 0403:

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.


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