Quote:
Originally Posted by j.p.s
C compilers, by default, feel free to ignore arithmetic operator precedence, even when parentheses are used to (attempt to) force operation order.
|
No non-broken C compiler should ignore operator precedence. It just might not mean what you think it does - e.g. it doesn't control the order of evaluation of operands, only the order of execution of the operators (and even then compilers are allowed to reorder expressions so long as it doesn't alter the observable behaviour of the program). K&R C gave a bit more latitude around reordering expressions that were mathematically associative or commutative, but not necessarily computationally so, but ANSI/ISO C tightened that up.
Obviously, if your program has undefined behaviour, then the compiler can do whatever it wants, but the problem there is with the undefined behaviour, not the reordering!