A side effect changes an object or other program state while an expression is evaluated. In C, `an_object @= some_expression;` both computes a value and modifies `an_object`; increment and decrement operators behave similarly. section 4.2 section 19.0
Prefix, postfix, and chained modification
`++a` increments `a` before producing its result, whereas `a++` produces the old value before incrementing `a`. A chained expression such as `a = b = c += ++d` combines several modifications, making its evaluation difficult to follow. Write separate statements instead of relying on such expressions. section 4.2
TAKEAWAYS
- Treat side effects inside value expressions as a readability and correctness hazard. section 4.2
- Modify no more than one object in a statement. section 4.2
- Do not assume that arithmetic operators or function calls evaluate operands or arguments in a particular order. section 4.5
- Keep functions called inside expressions free of side effects when evaluation order matters. section 4.5
Unreliable argument order
In `printf("%g and %g\n", f(a), f(b));`, C does not establish whether `f(a)` or `f(b)` runs first. If either function modifies state relevant to the other, the result can depend on compiler choices or surrounding code. section 4.5
Side effects are one kind of effect. Program execution can also change its point of execution, intermediate values, or hidden state such as lock and atomic-flag state. Even `(void)0` has an effect because execution advances to the next evaluation. section 19.0























