From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by sourceware.org (Postfix) with ESMTPS id AC0763858D32; Fri, 7 Apr 2023 21:38:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AC0763858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-244acf4a2f5so164314a91.3; Fri, 07 Apr 2023 14:38:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680903530; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=oclLYvy06kMAcfw+LL15PrqgLjEKuu6LzR/72r04Qks=; b=Yi15oEd0ABpk+mTIQoI3IkUwixoH3EPXr+fVc5Z2xMkMGaG4vkjbS+eIDww3gS5tdZ jHVMH145JxCySGTwOhB+aZt3j/v1UihHCMBY3UpZ88NoelCcu85s4+2JqXG/4Pn0a7gi +BuWSsrdagVKCVRIhUTVGKLO9lhe/aDwQAbIK8CiCjwaKXqsmwZ2U+Sx+rx7Sec91538 yYcJyXdobC4yPCZNYpat9NekV21NXqa4FN3cG3aPiY2gFER4kojCVN5Zq6fPqftynPzz vxwr/t+FdIOhTgVlArd1bPweYlz0BeLGbWotJUNSew3ZmNuYpmJW/6TbXlXpa/DF36Dj cihg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680903531; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=oclLYvy06kMAcfw+LL15PrqgLjEKuu6LzR/72r04Qks=; b=GQWkhk0MgD3DN+q1mhZoZXR7Waisr/TnmKMJN+WaKksqs5wAoOBOKlp2DsvuZyVj+Z kiL1+Ad+jqkspI0qoZ6SZgR6Jl2ZIYQdDZbR5ZHP8vEFs9x6ip3Ws7iUoBEO4WdWxfzf TjxmKMrCVzsH74NB/mRMNRk74ZDrXp2Cf8LDA8pz3kdYypFVR5w20SJQ+BcQUIgYi3Mn I1LhQhO6+9TBXERwh+kDHMA2FCuynaa5fm2xU7ftykPf8dFg/6+W5WWtDiBpb9AXtj3f F95yheh7Ab92TJblIScqtBuYEGaMFsGIpjaT0DGHx0Lrc1/0mGLcz9PXyKUgBzdCCMAP arNQ== X-Gm-Message-State: AAQBX9eZXr4msyNTnV/zsf/IVSW4p+T57gNmSgrWv08gBrcMSie8NFFX Tl+kaylH+BUbWhcVXahU3XKko6kMR8gQpvfgt/6CuxsM X-Google-Smtp-Source: AKy350a6lABY86sE0f6IzP1YXnvEUGta4SMF7pXjdZJzUv02RqKAOe184RQSLGrfWOfiYwVShCYB0BpXPlYZzpggk5U= X-Received: by 2002:a05:6a00:2391:b0:627:e6d5:ba2d with SMTP id f17-20020a056a00239100b00627e6d5ba2dmr1778721pfc.6.1680903530522; Fri, 07 Apr 2023 14:38:50 -0700 (PDT) MIME-Version: 1.0 References: <67044cbd-2fa5-8abf-e1d2-42fb150d0124@gmx.de> <1b87744e-5e9a-f932-21e8-64d122f74a5c@gmx.de> In-Reply-To: From: Paul Richard Thomas Date: Fri, 7 Apr 2023 22:38:39 +0100 Message-ID: Subject: Re: Ping! [Patch, fortran] PR87477 - [meta-bug] [F03] issues concerning the ASSOCIATE statement To: Harald Anlauf Cc: "fortran@gcc.gnu.org" , gcc-patches Content-Type: multipart/alternative; boundary="000000000000d6ab6505f8c5d910" X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,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: --000000000000d6ab6505f8c5d910 Content-Type: text/plain; charset="UTF-8" PS Quite right about the allocation in PR93813 - consider it to be included. Cheers and thanks Paul On Fri, 7 Apr 2023 at 22:35, Paul Richard Thomas < paul.richard.thomas@gmail.com> 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. > @@ -2554,23 +2559,25 @@ gfc_conv_string_length (gfc_charlen * cl, gfc_expr > * expr, stmtblock_t * pblock) > expr_flat = 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 = convert (gfc_charlen_type_node, > se.string_length); > - > + if (expr_flat->rank) > + gfc_conv_expr_descriptor (&se, expr_flat); > + else > + gfc_conv_expr (&se, expr_flat); > + if (expr_flat->expr_type != EXPR_VARIABLE) > + gfc_add_block_to_block (pblock, &se.pre); > + se.expr = 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 = 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 = 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 >> >> >> >> >> > >> >> > > -- > "If you can't explain it simply, you don't understand it well enough" - > Albert Einstein > -- "If you can't explain it simply, you don't understand it well enough" - Albert Einstein --000000000000d6ab6505f8c5d910--