3 ms·
Indeed: "The ANSI Fortran standard is less restrictive than the C standard: it requires the compiler to respect the order of evaluation specified by parentheses
by Joky 12y ago
Indeed: "The ANSI Fortran standard is less restrictive than the C standard: it requires the compiler to respect the order of evaluation specified by parentheses, but otherwise allows the compiler to reorder expressions as it sees fit."
- kazinator 12y agoThat piece of text, if taken literally and perhaps out of context, means that if we have a * b + c, the Fortran compiler is allowed to add b+c first, and then multiply by a, because there are no parentheses. It's just a question of whether the compiler writers "sees fit" such a thing. In C, the order of operations is not ambiguous, and is distinct from the evaluation order. In a * b + c, three operands a, b and c have to be evaluated (the variables be reduced to the operand values they hold). This evaluation takes place in an unspecified order (possibly leading to undefined behavior). On these values, however, the arithmetic order of operations is clear: multiplication takes precedence and so is done first. The evaluation order makes a difference if the expressions a, b and c themselves have side effects.