rev2217/norm: The standards of most programming languages, including Fortran and C/C++, explicitly forbid optimizations that fail to preserve the integrity of parentheses in order to give programmers control of the sequence of operations when it matters. Thus, such an optimization is illegal.This is (or was) part of the FORTRAN (IV) standard; I can't say about newer FORTRANs, though I doubt it has changed. It is *not* part of the C standard, and never has been. C guarantees ordering of statements separated by &&, ||, ^^, and a few others, but guarantees nothing about optimization. From Harbison & Steele, Fifth Edition, Section 7.3.3, "Parenthesized Expressions": "Parentheses do not necessarily force a particular evaluation order.... The purpose of the parenthesized expression is simply to delimit the enclosed expression for grouping purposes, either to defeat the default precedence of operators or make the code more readable."That said, I doubt that many C optimizers would apply this identity to optimize this expression.rj
Best Of |
Favorites & Replies |
Start a New Board |
My Fool |
BATS data provided in real-time. NYSE, NASDAQ and NYSEMKT data delayed 15 minutes.
Real-Time prices provided by BATS. M