This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Difference between -Os and -O2


Chao Hieu,

I don't know if this is possible for your target environment, but if
possible, try running valgrind or similar memory-debugging tool.  If
not, examine your code carefully for possible access of uninitialized
memory, etc.  I have found that very often (but not always), what at
first seems to us to be compiler generating incorrect code is, in fact,
our own bad code.  Code that produces behavior that differs between
optimization options is often the result of access of uninitialized
memory.  Otherwise, as others have suggested, look at the assembly, but
this is likely only helpful if your program is small or you can narrow
the problem down to a particular small portion of the code.

Good luck,
-- David Favro


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]