J
John Devereux
- Jan 1, 1970
- 0
Joel Koltner said:Yes, you certainly do.
There's probably a setting where you can get the optimizer to issue
warnings when it completely removes a chunk of code.
However, the idea is that -- in many cases, with more complex code --
it might not be obvious to the casual observer that a particular chunk
of code is constant-value or otherwise always does the same thing and
hence can be eliminated; if you were to examine a large, complex piece
of code such as a web browser, you'd probably be quite surprised just
how many optimizations the compiler is able to find (including how
many lines of code can be eliminated). Heck, these days many people
advocate writing code that makes it more obvious what's happening
under the assumption that the compiler will perform optimization,
e.g., writing "if ( x & (1<<15) )" to test bit 15 of x rather than
writing "if (x & 0xf000)".
Nicely demonstrating your point, since it's x & 0x8000
[...]