View Single Post
Old 03-13-2023, 12:06 PM   #1407
jbjb
Somewhat clueless
jbjb ought to be getting tired of karma fortunes by now.jbjb ought to be getting tired of karma fortunes by now.jbjb ought to be getting tired of karma fortunes by now.jbjb ought to be getting tired of karma fortunes by now.jbjb ought to be getting tired of karma fortunes by now.jbjb ought to be getting tired of karma fortunes by now.jbjb ought to be getting tired of karma fortunes by now.jbjb ought to be getting tired of karma fortunes by now.jbjb ought to be getting tired of karma fortunes by now.jbjb ought to be getting tired of karma fortunes by now.jbjb ought to be getting tired of karma fortunes by now.
 
Posts: 780
Karma: 10535853
Join Date: Nov 2008
Location: UK
Device: Kindle Oasis
Quote:
Originally Posted by j.p.s View Post
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!
jbjb is offline   Reply With Quote