From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13922 invoked by alias); 28 Sep 2011 00:03:21 -0000 Received: (qmail 13910 invoked by uid 22791); 28 Sep 2011 00:03:21 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-pz0-f47.google.com (HELO mail-pz0-f47.google.com) (209.85.210.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 28 Sep 2011 00:03:07 +0000 Received: by pzk4 with SMTP id 4so20326736pzk.6 for ; Tue, 27 Sep 2011 17:03:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.14.129 with SMTP id p1mr33036949pbc.35.1317168186949; Tue, 27 Sep 2011 17:03:06 -0700 (PDT) Received: by 10.143.30.6 with HTTP; Tue, 27 Sep 2011 17:03:06 -0700 (PDT) In-Reply-To: References: Date: Wed, 28 Sep 2011 06:15:00 -0000 Message-ID: Subject: Re: Question on Taming the Optimizer From: Jonathan Wakely To: noloader@gmail.com Cc: GCC Users List Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2011-09/txt/msg00227.txt.bz2 On 28 September 2011 00:41, Jeffrey Walton 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 >