This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: Difference between -Os and -O2
Nicholas,
I'm not sure that I can try with Valgrind, because it's a shared
library. And the Valgrind does not work on MIPS. I have the code
compiled successful on x86, but the issue currently is shared library.
I've create an empty executable file, link with the .so and try to run
with Valgrind but I'm not sure it is correct or not.
Is there any way to use Valgrind with a shared library?
Regards,
-Hieu
-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
Behalf Of Nicholas Sherlock
Sent: Monday, April 27, 2009 12:47 PM
To: gcc-help@gcc.gnu.org
Subject: Re: Difference between -Os and -O2
Hieu Le Trung wrote:
> Hi,
>
> I'm currently facing an issue with -Os and -O2 optimization level. My
> program can be compiled with both case, but it's not stable for -Os
> flag. It makes my application crash sometimes.
>
>
The overwhelming likelihood is that your program is buggy - overwriting
array bounds or accessing free'd memory. A small change in the memory or
stack layout of your prgoram (from -Os and -O2) can make your bug
visible or hide it. Run it through a memory debugger like Valgrind,
dmalloc, Electric Fence, etc.
Cheers,
Nicholas Sherlock