It is best to make your optimization and/or debugging choices explicit:
If you need to debug your program excluding any optimization effect, use the -O0 option, which turns off all the optimizations.
If you need to debug while still use optimizations, you can specify the -O1 or -O2 options on the command line along with -g.
If you do not make your optimization choice explicit when -g is specified, the -g option implicitly disables optimization (as if -O0 were specified).
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.
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. |