Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The assert() statement is a convenient mechanism for incorporating diagnostic tests in code. Expressions used with the standard assert statement should not have side effects. Typically, the behavior of the assert statement depends on the status of a runtime property. If defined, the assert statement is defined to evaluate its expression argument and abort throw an exception if the result of the expression is convertible to false. If undefined, assert is defined to be a no-op. Consequently, any side effects resulting from evaluation of the expression in the assertion are lost in non-debugging versions of the code.

...

Avoid the possibility of side effects in assertions. This can be achived achieved by decoupling the boolean from the assertion.

...