Debugging and Optimizations

It is best to make your optimization and/or debugging choices explicit:

If you do not make your optimization choice explicit when -g is specified, the -g option implicitly disables optimization (as if -O0 was specified).

-fp Option and Debugging (IA-32 only)

The -fp option disables use of the ebp register in optimizations, and can result in slightly less efficient code. With this option, the compiler generates code for IA-32-targeted compilations without turning off optimization, so that a debugger can still produce a stack backtrace.

If you specify the -O1 or -O2 options, the -fp option is disabled. If you specify the -O0 option, -fp is enabled. Remember that the -fp option affects IA-32 applications only.

Summary

Refer to the table below for the summary of the effects of using the -g option with the optimization options.

These options

Imply these results

-g

debugging information produced, -O0 enabled, -fp enabled for IA-32-targeted compilations.

-g -O1

debugging information produced, -O1 optimizations enabled, -fp disabled for IA-32-targeted compilations

-g -O2

debugging information produced, -O2 optimizations enabled, -fp disabled for IA-32-targeted compilations

-g -O3 -fp

debugging information produced, -O3 optimizations enabled, -fp enabled for IA-32-targeted compilations.

-g -ip

limited debugging information produced, -ip option enabled.