Re: How safe is gcc -O3 ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Dr. David Kirkby" <david.kirkby@xxxxxxxxxx> writes:

> How safe is it to distribute code for others to build, where you have
> selected -O3 for them? I'm a bit concerned that might be a bit
> aggressive to use as a default, given it will potentially be compiled
> by different gcc versions on different platforms.

The -O3 optoin should be safe for correct code.  An important difference
between -O2/-O3 and -O1 is that -O2 and -O3 enable strict aliasing and
strict overflow.  Those options provide better optimization for correct
code, but are far more likely to cause unexpected code generation for
incorrect code.  See the -fstrict-aliasing and -fstrict-overflow
options.

> I believe -O2 might be a more sensible default, but would welcome the
> opinions of others on the matter.

The main difference between -O3 and -O2 is that -O3 enables more
speculative optimizations.  These should not miscompile your code, but
they may cause your program to run more slowly.

Ian


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux