![]() |
![]() |
0402 | ![]() |
||||
![]() | |||||||
| Explicitly undefined | REFERENCE - ISO:C90-6.3 Expressions | ||||||
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 in the C language. Message 0402 is generated when the ordering of an access to an object and a definite modification of the object are undefined. Definite sources of modification are associated with assignment operations and increment and decrement operations. In the code examples shown below:
/*PRQA S 506,2017,3120,3199,3408,3416,3422,3440,3441,3447,3673 ++*/
extern void func(int x, int y);
extern void foo(int buf[], int index)
{
int r;
r = (2 * index) + index++; /* a) Message 0402 */
buf[++r] == buf[r]; /* b) Message 0402 */
func(r, r++); /* c) Message 0402 */
r = r + 1; /* d) OK */
}
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |