Actions

EmSys

CCoding Style - Be careful with side effects

From EdWiki

Revision as of 09:30, 23 June 2015 by Jshankar (Talk | contribs) (1 revision imported: EdWiki -- Emsys pages from Shukra)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Be careful with side effects

  • Operators like ++ have side effects: besides returning a value, they also modify an underlying variable.
  • Side effects can be extremely convenient, but they can also cause trouble because the actions of retrieving the value and updating the variable might not happen at the same time.
  • In C, the order of execution of side effects is undefined.