From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29174 invoked by alias); 4 Nov 2010 08:51:05 -0000 Received: (qmail 29155 invoked by uid 22791); 4 Nov 2010 08:51:04 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mx01.qsc.de (HELO mx01.qsc.de) (213.148.129.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 04 Nov 2010 08:50:57 +0000 Received: from [192.168.178.22] (port-92-204-92-55.dynamic.qsc.de [92.204.92.55]) by mx01.qsc.de (Postfix) with ESMTP id 82FE23CD8C; Thu, 4 Nov 2010 09:50:54 +0100 (CET) Message-ID: <4CD273ED.7040903@net-b.de> Date: Thu, 04 Nov 2010 08:56:00 -0000 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101026 SUSE/3.1.6 Thunderbird/3.1.6 MIME-Version: 1.0 To: Paul Richard Thomas CC: fortran@gcc.gnu.org, gcc-patches , Dominique Dhumieres Subject: Re: (Re)allocation of allocatable arrays on assignment - F2003 References: <20101009134002.157E83BE0F@mailhost.lps.ens.fr> <20101023202653.2DF9D3BE18@mailhost.lps.ens.fr> <4CC47A12.7050504@net-b.de> <20101031215043.8B69A3BE18@mailhost.lps.ens.fr> <20101101101824.F0F663BE18@mailhost.lps.ens.fr> <20101102222221.CB2BB3BE18@mailhost.lps.ens.fr> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2010-11/txt/msg00395.txt.bz2 Dear Paul, thanks for the patch. On 11/04/2010 07:18 AM, Paul Richard Thomas wrote: > In addition to correcting bugs, the main addition to the patch is the > option -f(no-)realloc_lhs. Default behaviour for -std> f95 is to > reallocate on assignment. I think a '-' instead of a '_' is more in line with most GCC and gfortran options; essentially only Darwin and SH use some '_' in the flags. While most of the patch uses realloc_lhs, there is at least one place where realloc-lhs is used. (As Intel uses "-assume realloc_lhs", the '_' has also some merits.) Thus, please make the use of '-' vs. '_' consistent and consider using a hyphen instead of an underscore. Additionally, the gfortran manpage (as the gcc one) states: In some cases, options have positive and negative forms; the negative form of -ffoo would be -fno-foo. This manual documents only one of these two forms, whichever one is not the default. As -std=gnu is the default, which implies -frealloc-lhs/-frealloc_lhs, we should document -fno-realloc-lhs/-fno-realloc_lhs instead. Sorry for missing this when I wrote the patch. > Please note that allocatable assignments of the kind: > x = transformational_array_intrinisic (...) > now produce a temporary unless -fno-realloc_lhs or -std=f95 are > deployed. This could be fixed relatively easily by detecting the > option in the library and repeating the logic of > gfc_alloc_allocatable_for_assignment there. I think that would be useful - also for cases such as a = abs(a) where the RHS is a elemental* function as one knows that the LHS and RHS must have the same shape. However, such a patch can be deferred. > Bootstrapped and regtested on FC9/x86_64 - OK for trunk? The patch looks OK. @@ -3676,6 +3700,11 @@ gfc_conv_loop_setup (gfc_loopinfo * loop, locus * where) continue; } + /* Avoid using an allocatable lhs in an assignment, since + there might be a reallocation coming. */ + if (loopspec[n] && ss->is_alloc_lhs) + continue; + I was wondering whether one should also add a "gfc_option.flag_realloc_lhs &&" to the if. +} + +/* Allocate the lhs of an assignment to an allocatable array, otherwise Add another empty line before the comment. Tobias