Oracle® Solaris Studio 12.4: C User's Guide

Exit Print View

Updated: March 2015
 
 

6.9.5 The As If Rule

Some reasons for the K&R C rearrangement rules are:

  • The rearrangements provide many more opportunities for optimizations, such as compile-time constant folding.

  • The rearrangements do not change the result of integral-typed expressions on most machines.

  • Some of the operations are both mathematically and computationally commutative and associative on all machines.

The ISO C Committee eventually decided that the rearrangement rules were intended to be an instance of the as if rule when applied to the described target architectures. ISO C’s as if rule is a general license that permits an implementation to deviate arbitrarily from the abstract machine description as long as the deviations do not change the behavior of a valid C program.

Thus, all the binary bitwise operators (other than shifting) are allowed to be rearranged on any machine because such regroupings are not noticeable. On typical two’s-complement machines in which overflow wraps around, integer expressions involving multiplication or addition can be rearranged for the same reason.

Therefore, this change in C does not have a significant impact on most C programmers .