Question on Taming the Optimizer

Jonathan Wakely jwakely.gcc@gmail.com
Wed Sep 28 06:15:00 GMT 2011


On 28 September 2011 00:41, Jeffrey Walton <noloader@gmail.com> wrote:
> Hi All,
>
> What is the preferred way to tame the optimizer when two class
> functions are producing incorrect results?

Fix your code ;-)

> There's not much to the class - its a vector with copy semantics. So
> it mirrors all vector's public functions, and forwards calls through
> the internal vector pointer. The pointer is a boost shared_ptr.
>
> -O2 is giving problems. -O0 is OK, Intel ICC is OK, and Visual Studio is OK.

As suggested at http://gcc.gnu.org/bugs/ you can try
-fno-strict-aliasing and -fwrapv, if they help your code is broken.

You can also turn off other individual optimisations with -fno-foobar,
see the manual for the various optimizations that are active at -O1
and -O2


> Jeff
>



More information about the Gcc-help mailing list