From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by sourceware.org (Postfix) with ESMTPS id 0B1583858D28; Sat, 8 Apr 2023 13:56:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0B1583858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1680962190; i=anlauf@gmx.de; bh=AmtABnvcKJAzokzhtWURQp6gEKgzgGnu7cJVctz9AY0=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=rKWORCVdbbNUobfRZToNuESn6lj3cJ9YR91XbjtQVfSif2N16nbzgU92pNpJx/d78 5eaOJT3xs7K/OMQMKhmyyCdXIO+TeFsSEe8PV0HmctG54uDdOUJtAxgVsW9r+tx9rc /OQB+RPlHb4cltPiKbNuTDjUS3daUmS9ipnEYmCAnbHXcKVPIeWsYjKHBMYS1SpGcp yFVd1+5h2hTVLTt/xRp507YlVBZH52HqKo0u/A+iKOUj2cdIIGVbhwR81qnKqQgT34 8v9yBI86THsaKzYwdL9HnNnuUBg6X1tQuH+aKbyG/DevtZCHrVkUx/oiMsWjflQtGr iTSKA35S4g6yw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.178.29] ([79.232.148.228]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M26vL-1pn4zf2xPV-002ZtH; Sat, 08 Apr 2023 15:56:30 +0200 Message-ID: <65c13c56-1796-3a33-2391-224d588310a3@gmx.de> Date: Sat, 8 Apr 2023 15:56:29 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: Ping! [Patch, fortran] PR87477 - [meta-bug] [F03] issues concerning the ASSOCIATE statement Content-Language: en-US To: Paul Richard Thomas Cc: "fortran@gcc.gnu.org" , gcc-patches Newsgroups: gmane.comp.gcc.patches,gmane.comp.gcc.fortran References: <67044cbd-2fa5-8abf-e1d2-42fb150d0124@gmx.de> <1b87744e-5e9a-f932-21e8-64d122f74a5c@gmx.de> From: Harald Anlauf In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:h6Vux8/UxKFjib6p3Ji+Vj9lpNJKFRAD6IotOhrAm1LoRp7soBO JRTADrft9D6L6w6PEfWv3E2oNG5rIwR17V22g9Q7w2m90vRe4jAyplvN/mTcQTrJ3MFMCmE qExU9sSlRJ1WsSacn2aUhDr2cnZI0qa1n4DtAgEAScm20EmoG5UyM6Mga91jILipUfM0rAj W9lgAlzdJnLRC+lRegpRw== UI-OutboundReport: notjunk:1;M01:P0:iiQOSdHTR/I=;0Pi5A37HcDYjmoa5qIunh6/Wgyw lSTwZKHSdllgLkBdm/63stbmO2cUPYUNBrBxBDb7g2mfeNJ1892JbalK2wu7tn44YA2sJL5hI R/4dC1suUWV/6gkvgSy7DdOvPQeD2T00l3JcJdMesNNZ0uq/UsOrYEYEifEOWSKC3Xjlgs9YK lNR0uYy2am/ly2IX6LiSRnYLN143ruzyRBM7pELoVMTpDH797/O/8oACrHHIJOIPZtBsOZ11W +y58FsQBfi4jG2Co666kg+BrCshFCiJxZPiDeSI4iK9xXeJhc6zOvNrF1/4lB8Tvg1Lxuq4qK /CWtTJtKeqggKwo+IrN8HuhFaInqRewMzy2PlAgzByB8K8Lq2LnGgfO3qq21bA6qr1UHdmkkX gIhjncAlFgUyKp/mq/yLSOXSf4h7Cq8CtQnLd/Ys6LH2Jp8UOey9roCb9zp4pkBu5kpckVHyS 6EnTYblu6fGi/odqejTnG/fee9rX3kHkeoV16I1ccWMus8YndnbAm7LytrQasxl0Z/Gzm8eIp DgHBUQ5dOWe6xdPTGk1ZCWMZOYFdGaL/aKICOtnAhCrKvyJwHLIS6UfV6yjoIvusFXzRjO+AP RGvHiwkcDpfbXh+MwibyBzM3rbIcSt8C619YRVqi44LKIr5OYvXn3TqrV5ds5g81aI5fyGAPM wJDMPKx4iKhiXXrH6dV3mffjftCK1Ysi+yLca9my6Xc7pTnnEPmFadZe6FJFerMN6L0qv4BQX H/rfIWm3xl6zaG8xjGl4EOJV21PBihWnbvaSQ8Qpa2H02mB/xrGiZyqnp8qWYcqCVRGMTbtTo kvID4qv1o/KPmUssi9vS3kWnQu4laquq7FueKWGhM9Xe3LLzMOdC4vt3foH9m6BQ6a5479PtH PW0q7tSSiGl2T3ff9T2Nd+FqoLtMg9oH5YqkCFuS3sI9hLcM6ZyVFev5fwz5lDohSvEHaxfX6 gRMMTJStSYkJqnz2cC439LWxyss= X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Paul, On 4/7/23 23:35, Paul Richard Thomas via Gcc-patches wrote: > Hi Harald, > > Well done on noticing the memory leak :-) I have a fix for it that I was > going to post separately. Actually, it is a trivial one liner, which I > could include with the patch. thanks for addressing this! I can confirm that this correction does the job. Great work! Harald > @@ -2554,23 +2559,25 @@ gfc_conv_string_length (gfc_charlen * cl, gfc_ex= pr > * expr, stmtblock_t * pblock) > expr_flat =3D gfc_copy_expr (expr); > flatten_array_ctors_without_strlen (expr_flat); > gfc_resolve_expr (expr_flat); > - > - gfc_conv_expr (&se, expr_flat); > - gfc_add_block_to_block (pblock, &se.pre); > - cl->backend_decl =3D convert (gfc_charlen_type_node, se.string_le= ngth); > - > + if (expr_flat->rank) > + gfc_conv_expr_descriptor (&se, expr_flat); > + else > + gfc_conv_expr (&se, expr_flat); > + if (expr_flat->expr_type !=3D EXPR_VARIABLE) > + gfc_add_block_to_block (pblock, &se.pre); > + se.expr =3D convert (gfc_charlen_type_node, se.string_length); > + gfc_add_block_to_block (pblock, &se.post); > // <<>> > gfc_free_expr (expr_flat); > - return; > } > - > - /* Convert cl->length. */ > - > - gcc_assert (cl->length); > - > - gfc_conv_expr_type (&se, cl->length, gfc_charlen_type_node); > - se.expr =3D fold_build2_loc (input_location, MAX_EXPR, > gfc_charlen_type_node, > - se.expr, build_zero_cst (TREE_TYPE (se.expr= ))); > - gfc_add_block_to_block (pblock, &se.pre); > + else > + { > + /* Convert cl->length. */ > + gfc_conv_expr_type (&se, cl->length, gfc_charlen_type_node); > + se.expr =3D fold_build2_loc (input_location, MAX_EXPR, > + gfc_charlen_type_node, se.expr, > + build_zero_cst (TREE_TYPE (se.expr))); > + gfc_add_block_to_block (pblock, &se.pre); > + } > > if (cl->backend_decl && VAR_P (cl->backend_decl)) > gfc_add_modify (pblock, cl->backend_decl, se.expr); > > Cheers > > Paul > > > On Fri, 7 Apr 2023 at 20:28, Harald Anlauf wrote: > >> Hi Paul, >> >> On 4/7/23 15:53, Paul Richard Thomas via Gcc-patches wrote: >>> duuuh! Please find them attached. >> >> the patch LGTM. Thanks! >> >> However, I have comments on the new testcase associate_60.f90: >> subroutine pr93813 is missing an allocation of x, e.g.: >> >> allocate (t :: x) >> >> otherwise it would be invalid. Please check and fix. >> >> Interestingly, subroutine pr92779 exhibits a small memory leak >> with memory allocated by the spread intrinsic. I played a little >> and found that the leak depends on the presence of trim(): omitting >> trim() removes the leak. But looking at the related pr, it seems >> that trim() was essential, so omitting it is likely not an option. >> >> I think the best way is to proceed and to open a PR on the memory >> leak rather than leaving pr92779 open. What do you think? >> >> Cheers, >> Harald >> >> >>> Thanks >>> >>> Paul >>> >>> >>> On Fri, 7 Apr 2023 at 10:41, Harald Anlauf wrote: >>> >>>> Hi Paul, >>>> >>>> I don't see the new testcases. Is this an issue on my side, >>>> or did you forget to attach them? >>>> >>>> Thanks, >>>> Harald >>>> >>>> On 4/7/23 09:07, Paul Richard Thomas via Gcc-patches wrote: >>>>> Dear All, >>>>> >>>>> Please find attached a slightly updated version of the patch with a >>>>> consolidated testcase. The three additional testcases are nothing to= do >>>>> with associate and test fixes of character related bugs. >>>>> >>>>> OK for mainline? >>>>> >>>>> Cheers >>>>> >>>>> Paul >>>>> Fortran: Fix some of the bugs in associate [PR87477] >>>>> >>>>> 2023-04-07 Paul Thomas >>>>> >>>>> gcc/fortran >>>>> PR fortran/87477 >>>>> * resolve.cc (resolve_assoc_var): Handle parentheses around the >>>>> target expression. >>>>> (resolve_block_construct): Remove unnecessary static decls. >>>>> * trans-array.cc (gfc_conv_expr_descriptor): Guard string len >>>>> expression in condition. Improve handling of string length and >>>>> span, especially for substrings of the descriptor. >>>>> (duplicate_allocatable): Make element type more explicit with >>>>> 'eltype'. >>>>> * trans_decl.cc (gfc_get_symbol_decl): Emit a fatal error with >>>>> appropriate message instead of ICE if symbol type is unknown. >>>>> * trans-expr.cc (gfc_get_expr_charlen): Retain last charlen in >>>>> 'previous' and use if end expression in substring reference is >>>>> null. >>>>> (gfc_conv_string_length): Use gfc_conv_expr_descriptor if >>>>> 'expr_flat' is an array. >>>>> (gfc_trans_alloc_subarray_assign): If this is a deferred string >>>>> length component, store the string length in the hidden comp. >>>>> Update the typespec length accordingly. Generate a new type >>>>> spec for the call to gfc_duplicate-allocatable in this case. >>>>> * trans-io.cc (gfc_trans_transfer): Scalarize transfer of >>>>> deferred character array components. >>>>> >>>>> >>>>> gcc/testsuite/ >>>>> PR fortran/87477 >>>>> * gfortran.dg/finalize_47.f90 : Enable substring test. >>>>> * gfortran.dg/finalize_51.f90 : Update an error message. >>>>> >>>>> PR fortran/85686 >>>>> PR fortran/88247 >>>>> PR fortran/91941 >>>>> PR fortran/92779 >>>>> PR fortran/93339 >>>>> PR fortran/93813 >>>>> PR fortran/100948 >>>>> PR fortran/102106 >>>>> * gfortran.dg/associate_60.f90 : New test >>>>> >>>>> PR fortran/98408 >>>>> * gfortran.dg/pr98408.f90 : New test >>>>> >>>>> PR fortran/105205 >>>>> * gfortran.dg/pr105205.f90 : New test >>>>> >>>>> PR fortran/106918 >>>>> * gfortran.dg/pr106918.f90 : New test >>>> >>>> >>> >> >> >