From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25669 invoked by alias); 21 Nov 2011 20:23:04 -0000 Received: (qmail 25653 invoked by uid 22791); 21 Nov 2011 20:22:59 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_SG X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 21 Nov 2011 20:22:05 +0000 From: "sgk at troutmask dot apl.washington.edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/51218] [4.7 Regression] Potential optimization bug due to implicit_pure? Date: Mon, 21 Nov 2011 21:08:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: sgk at troutmask dot apl.washington.edu X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.7.0 X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-11/txt/msg02148.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51218 --- Comment #18 from Steve Kargl 2011-11-21 20:21:01 UTC --- On Mon, Nov 21, 2011 at 08:02:20PM +0000, burnus at gcc dot gnu.org wrote: > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51218 > > --- Comment #17 from Tobias Burnus 2011-11-21 20:02:20 UTC --- > (In reply to comment #16) > > One thing it relies on is that the compiler recognizes > > that the bad function are not pure, as they have a > > side effect (e.g. accessing module variable call_level). > > If a side effect is able to disable critical optimizations, > > then I'm optimistic that the code will work on most platforms. > > > > Now as promised, here's the reduced example: > > Thanks for the example! > > Untested patch: > > --- a/gcc/fortran/resolve.c > +++ b/gcc/fortran/resolve.c > @@ -3257,6 +3255,7 @@ pure_subroutine (gfc_code *c, gfc_symbol *sym) > else if (gfc_pure (NULL)) > gfc_error ("Subroutine call to '%s' at %L is not PURE", sym->name, > &c->loc); > + gfc_current_ns->proc_name->attr.implicit_pure = 0; > } Harald's example has function calls not subroutines. I would expect that you need to set this in pure_function as well. Also, does this type of change inhibit reason why implicit_pure was added in the first place?