The compiler lets you generate code to support symbolic debugging while the -O1 or -O2 optimization options are specified on the command line along with -g. However, you can receive these unexpected results:
If you specify the -O1 or -O2 options with the -g option, some of the debugging information returned may be inaccurate as a side-effect of optimization.
If you specify the -O1 or -O2 options, the -fp option will not be disabled. In this case, if you want to maintain the frame pointer while generating debug information, you must explicitly specify the -fp- option on the command line to disable -fp.
The table below summarizes the effects of using the -g option with the optimization options.
These options |
Imply these results |
-g |
debugging information produced, -O0, -fp disabled |
-g -O0 |
debugging information produced, -O0 optimizations disabled |
-g -O2 |
debugging information produced, -O2 optimizations enabled |
-g -O2 -fp |
debugging information produced, -O2 optimizations enabled, -fp disabled |
-g -ip |
limited debugging information produced, -ip option enabled. |