TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
TIOBE - C Coding Standard

SR:  7#2Checked automatically with code checker

Synopsis:Expressions shall not contain multiple side-effects due either to the same identifier being modified more than once, or due to the same identifier being modified and accessed.
Severity Level:2

For all but a few constructs in C, Standard C does not define the evaluation order even where there may be side-effects. Reliance on them can create problems which are very expensive to track down.


x = i++ + a[i]; /* WRONG - 2 side effects x assigned and i changed */
x = i + a[i]; /* RIGHT */
Even something as simple as two function references in the same expression can lead to problems.


x = f() + g(); /* CAUTION - if f and g both modify and access the same externally visible identifier, big problemsmay result. */
t = f();
x = t + g(); /* SAFE, but may lead to expressions becoming hard to understand. */