From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ciao.gmane.io (ciao.gmane.io [116.202.254.214]) by sourceware.org (Postfix) with ESMTPS id EC0A53857724 for ; Fri, 14 Apr 2023 16:50:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EC0A53857724 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=m.gmane-mx.org Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1pnMdD-00042P-8t for gcc-patches@gcc.gnu.org; Fri, 14 Apr 2023 18:50:39 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: gcc-patches@gcc.gnu.org From: Harald Anlauf Subject: Re: [Patch, fortran] PR109451 - ICE in gfc_conv_expr_descriptor with ASSOCIATE and substrings Date: Fri, 14 Apr 2023 18:50:31 +0200 Message-ID: References: <2ef9c2f2-2b56-2dd1-15cb-ff3318ea1315@gmx.de> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Content-Language: en-US In-Reply-To: Cc: fortran@gcc.gnu.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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: Message-ID: <20230414165031.kCSe8BK_2qxenLxFr8LFMoXt1im2WBO1VgLXUpYmxiQ@z> Hi Paul, On 4/14/23 10:18, Paul Richard Thomas via Gcc-patches wrote: > Hi Harald, > > The fix was trivial. An updated patch and testcase are attached. great, this works, and I couldn't break it again this time ... Looks good! Thanks, Harald > Thanks > > Paul > > Fortran: Fix some deferred character problems in associate [PR109451] > > 2023-04-14 Paul Thomas > > gcc/fortran > PR fortran/109451 > * trans-array.cc (gfc_conv_expr_descriptor): Guard expression > character length backend decl before using it. Suppress the > assignment if lhs equals rhs. > * trans-io.cc (gfc_trans_transfer): Scalarize transfer of > associate variables pointing to a variable. Add comment. > * trans-stmt.cc (trans_associate_var): Remove requirement that > the character length be deferred before assigning the value > returned by gfc_conv_expr_descriptor. Also, guard the backend > decl before testing with VAR_P. > > gcc/testsuite/ > PR fortran/109451 > * gfortran.dg/associate_61.f90 : New test > > > On Thu, 13 Apr 2023 at 07:18, Paul Richard Thomas < > paul.richard.thomas@gmail.com> wrote: > >> Hi Harald, >> >> That's interesting - the string length '.q' is not set for either of the >> associate blocks. I'm onto it. >> >> Thanks >> >> Paul >> >> >> On Wed, 12 Apr 2023 at 20:26, Harald Anlauf wrote: >> >>> Hi Paul, >>> >>> On 4/12/23 17:25, Paul Richard Thomas via Gcc-patches wrote: >>>> Hi All, >>>> >>>> I think that the changelog says it all. OK for mainline? >>> >>> this looks almost fine, but still fails if one directly uses the >>> dummy argument as the ASSOCIATE target, as in: >>> >>> program p >>> implicit none >>> character(4) :: c(2) = ["abcd","efgh"] >>> call dcs0 (c) >>> ! call dcs0 (["abcd","efgh"]) >>> contains >>> subroutine dcs0(a) >>> character(len=*), intent(in) :: a(:) >>> print *, size(a),len(a) >>> associate (q => a(:)) >>> print *, size(q),len(q) >>> end associate >>> associate (q => a(:)(:)) >>> print *, size(q),len(q) >>> end associate >>> return >>> end subroutine dcs0 >>> end >>> >>> This prints e.g. >>> >>> 2 4 >>> 2 0 >>> 2 0 >>> >>> (sometimes I also get junk values for the character length). >>> >>> Can you please have another look? >>> >>> Thanks, >>> Harald >>> >>> >>>> Paul >>>> >>>> Fortran: Fix some deferred character problems in associate [PR109451] >>>> >>>> 2023-04-07 Paul Thomas >>>> >>>> gcc/fortran >>>> PR fortran/109451 >>>> * trans-array.cc (gfc_conv_expr_descriptor): Guard expression >>>> character length backend decl before using it. Suppress the >>>> assignment if lhs equals rhs. >>>> * trans-io.cc (gfc_trans_transfer): Scalarize transfer of >>>> associate variables pointing to a variable. Add comment. >>>> >>>> >>>> gcc/testsuite/ >>>> PR fortran/109451 >>>> * gfortran.dg/associate_61.f90 : New test >>> >>> >> >> -- >> "If you can't explain it simply, you don't understand it well enough" - >> Albert Einstein >> > >