From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30391 invoked by alias); 5 Feb 2015 19:59:39 -0000 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 Received: (qmail 30286 invoked by uid 48); 5 Feb 2015 19:59:35 -0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/64952] Missing temporary in assignment from elemental function Date: Thu, 05 Feb 2015 19:59: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-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-02/txt/msg00507.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64952 --- Comment #1 from Tobias Burnus --- Technical, it is a bit similar to: module m integer :: i contains pure subroutine f(x) integer, intent(inout) :: x x = 2*x + i end subroutine end module m which doesn't modify "i" but still feels a bit odd as it accesses an nonexplicitly passed variable. Thus, we may need to also take care of: array = elemental(array) * pure_function() where the pure_function accesses the array, e.g. as "sum(array)". Thus, not only "elemental" has to be checked for such an access, but also nonelemental pure functions in the surrounding. On the other hand, it would be probably faster to do: tmp = pure_function() array = elemental(array) * tmp which also avoids this problem. (The FE optimization might do this, but it should also correctly work with -O0.)