6.6 Optimization and debugging
With GCC it is possible to use optimization in combination with the
-g. Many other compilers do not allow this.
When using debugging and optimization together, the internal
rearrangements carried out by the optimizer can make it difficult to see
what is going on when examining an optimized program in the debugger.
For example, temporary variables are often eliminated, and the ordering
of statements may be changed.
However, when a program crashes unexpectedly, any debugging information
is better than none--so the use of
-g is recommended for
optimized programs, both for development and deployment. The debugging
-g is enabled by default for releases of GNU packages,
together with the optimization option