s*****s 发帖数: 27 | 1 无意中发现的,gdb调试
如果有-O2,用gdb调试时,逐行执行和源文件顺序不是完全一致
如果不用优化选项,还是一致的。 |
c****n 发帖数: 89 | 2 sure, never combine "-g" with "-O*".
that's how it optimized your code.
【在 s*****s 的大作中提到】 : 无意中发现的,gdb调试 : 如果有-O2,用gdb调试时,逐行执行和源文件顺序不是完全一致 : 如果不用优化选项,还是一致的。
|
e****m 发帖数: 484 | 3 You could/should combine them together in a lot of case.
you could then stripe the informtion if you need.
【在 c****n 的大作中提到】 : sure, never combine "-g" with "-O*". : : that's how it optimized your code.
|
c****n 发帖数: 89 | 4 can I ask you when you should have to combine them?
【在 e****m 的大作中提到】 : You could/should combine them together in a lot of case. : you could then stripe the informtion if you need.
|
a******e 发帖数: 95 | 5 when you need to make sure the compiler works correctly when
these two options are used together. LOL.
【在 c****n 的大作中提到】 : can I ask you when you should have to combine them?
|
c*r 发帖数: 278 | 6 when you are using GNU CC and want to debug optimized programs.
【在 c****n 的大作中提到】 : can I ask you when you should have to combine them?
|
c*r 发帖数: 278 | 7
Read the gcc manual:
"Unlike most other C compilers, GCC allows you to use -g with -O.
The shortcuts taken by optimized code may occasionally produce sur-
prising results: some variables you declared may not exist at all;
flow of control may briefly move where you did not expect it; some
statements may not be executed because they compute constant
results or their values were already at hand; some statements may
execute in different places because they were moved out of loops."
【在 s*****s 的大作中提到】 : 无意中发现的,gdb调试 : 如果有-O2,用gdb调试时,逐行执行和源文件顺序不是完全一致 : 如果不用优化选项,还是一致的。
|
c****n 发帖数: 89 | 8 looks weird, it's surely that one can combine two options together
and get no error. but what's the benefit from this combination? Do
we really need to dubug a optimized code???
【在 c*r 的大作中提到】 : : Read the gcc manual: : "Unlike most other C compilers, GCC allows you to use -g with -O. : The shortcuts taken by optimized code may occasionally produce sur- : prising results: some variables you declared may not exist at all; : flow of control may briefly move where you did not expect it; some : statements may not be executed because they compute constant : results or their values were already at hand; some statements may : execute in different places because they were moved out of loops."
|