Developer's Topics
Chapter 2, Complying with standard C

Grouping and evaluation in expressions

Grouping and evaluation in expressions

One of the choices made by Dennis Ritchie in the design of C was to give compilers license to rearrange expressions involving adjacent operators that are mathematically commutative and associative, even in the presence of parentheses. This was explicitly noted in the ``Reference Manual Appendix'' of The C Programming Language, Kernighan and Ritchie, (First Edition). ANSI C does not grant compilers this same freedom.

This section discusses the differences between these two definitions of C and clarifies the distinctions between an expression's side effects, grouping, and evaluation by considering the expression statement from the following code fragment.

   int i, *p, f(void), g(void);
   /*...*/
   i = *++p + f() + g();

This section is organized as follows: