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

Guideline:  7#3Checked automatically with code checker

Synopsis:Expressions containing multiple function references should be avoided due to the possibility of side-effects occurring in an undefined order.
Language:C
Severity Level:3
Category:EXPRESSIONS


Description:
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.

Example:

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

Example:

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. */