由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Unix版 - g++编译时加了优化代码选项是不是会改变代码顺序?
相关主题
GCC的编译?hOW CAN i COMPILE AND RUN FORTRAN?
GCC 一问#pragma
GCC 和 G++ 的区别在什么地方?Re: can I install fonts to view Chinese
help needed-install gcc/g++ 4.7 on ubuntu 14.04Questions about Makefile
A question about GCC[转载] 请教三个关于emacs和perl的问题
Install GCC on AIXA tough compiler problem
Is GCC able to do this?[转载] molscript and grasp
请问:装了GCC以后where is libstdc++
相关话题的讨论汇总
话题: optimized话题: combine话题: may话题: together话题: when
进入Unix版参与讨论
1 (共1页)
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."

1 (共1页)
进入Unix版参与讨论
相关主题
where is libstdc++A question about GCC
漆血柜求Install GCC on AIX
[转载] ask a question.Is GCC able to do this?
Help: convert // to /* */ in C code?请问:装了GCC以后
GCC的编译?hOW CAN i COMPILE AND RUN FORTRAN?
GCC 一问#pragma
GCC 和 G++ 的区别在什么地方?Re: can I install fonts to view Chinese
help needed-install gcc/g++ 4.7 on ubuntu 14.04Questions about Makefile
相关话题的讨论汇总
话题: optimized话题: combine话题: may话题: together话题: when