Difference between -Os and -O2

Nicholas Sherlock n.sherlock@gmail.com
Mon Apr 27 05:47:00 GMT 2009


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



More information about the Gcc-help mailing list