As-if rule

This mostly means that any actions the program performs on its environment occur in the specified order.

[2] The rule has three main exceptions in which behavior-changing optimizations are permitted.

The effect of the as-if rule depends on the specific compiler implementation.

As an example, in the Microsoft Visual C++ compiler, it causes omission of certain optimizations such as instruction reordering around calls to library functions, since such calls may cause input/output actions or accesses to memory locations marked volatile, and changes in the order of those change observable behavior.

have a similar rule, to permit optimization (notably inlining).