From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by sourceware.org (Postfix) with ESMTPS id 85F4B3855034; Wed, 11 Aug 2021 19:28:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 85F4B3855034 X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [93.207.86.61] ([93.207.86.61]) by web-mail.gmx.net (3c-app-gmx-bap04.server.lan [172.19.172.74]) (via HTTP); Wed, 11 Aug 2021 21:28:15 +0200 MIME-Version: 1.0 Message-ID: From: Harald Anlauf To: Harald Anlauf Cc: Tobias Burnus , Bernhard Reutner-Fischer , Harald Anlauf via Gcc-patches , fortran Subject: *PING* Re: [PATCH] PR fortran/100950 - ICE in output_constructor_regular_field, at varasm.c:5514 Content-Type: text/plain; charset=UTF-8 Date: Wed, 11 Aug 2021 21:28:15 +0200 Importance: normal Sensitivity: Normal In-Reply-To: References: <20210610122435.296a207d@nbbrfq> Content-Transfer-Encoding: quoted-printable X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:BtzTLm0w+cgOCh+kMOrhm+46Fu2oHpT1Sb7cVYw4Gz5zGwmYoLGod6cmGRLjxnhwIpFA3 2HDD6LDgxW24by1S7tIfzTQo+k/Bwq69ADw8imaohOdwuiHhDls+P49Mbse1HhlkdWxT5jJXl7HW 4wykjUeenUFrpA83gQk0Y1YBFLgVhpXtan/4OZcYIXdg6K2GUm12GedGiNFd50OIpXZRW2b83rHZ 54d5lUmnOUMm3k/BioMNN20QSyB1Sf1vfOnEGuGYHZyBY5K6T8fs4bGWJLcdVsouuKFI5AeouQiV Ug= X-UI-Out-Filterresults: notjunk:1;V03:K0:UO4BrL2sHmE=:R+rQBHVSEyfmkswFwIx8go NX3zBrBXmgR2k+IkAh9JWH3267+byZgkqI+cAu36/SqLsvDQ4otoukEiOqcNptMw1sNww+UF3 OazZhgoJk7ZmWzlsNfstKByV8lN3LdHb1yhePYUlzWb/nzMkL/290PaLEytpks1K14FdMrxAs P18UkkdpNQVEV6CmdF8ov3QF5M9SV50E/3dqKFWUHrXRPhoBnqyCGf78Zc6ORCqvnLntwh9eV Q2t0149CCoZejESmYv/djKHiGsunsCawITBLMuPRPDYexB5Emf2PI6jlySZffLEd5mJNgInO3 xt0343bbbzWhJkyAUwC0Bp6RzD/c8tl7aSIWlkLjVj22AbSXy+/vI1naXNuR2uBzI04v0hPMj gHRsH1DuWOAoJtVY/k9K9g2oqppdcp7R9VMy2Q9lMyXMAuL8113QL7h7CxQF1XrWYxbaCckr7 hFi/DPwakjWpkhS0Dy1wScFavA1KoTLcVYUOd6ND63moTVebPFrjKC5p73Hi/xgg9OoGDqsqE KhRICiB/ARA/4xO/pGuUPpo//9HmZGSxQK5cZxhIsb5e/mxPqxZOruvlfCbTKuo+vgN5r13cn XRITOTyMnoBswMNs2AMkUJc4Zuu41kJRn38IPHh021di0fjhQShtK9B0c4p5AQ2QWf+rf7sQD Jy5bg0XnmvI0YahVF0l3NdBHaAAXx71rYWU5cBt+nlWBkViM7WcUMHdYarxnlqylsS+XRs03K xOsDB4A8ybEv6HgLU+11iwv+ebIx3wJ0pQQLbg3+KF/u1F5ucW/mA9xMVKcYN7yotFyvtNMBJ 23A74z1BZ6rALcCuYFHy8QMyLpzNQ== X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 19:28:31 -0000 *Ping* > Gesendet: Dienstag, 03=2E August 2021 um 23:17 Uhr > Von: "Harald Anlauf" > An: "Harald Anlauf" > Cc: "Tobias Burnus" , "Bernhard Reutner-Fisc= her" , "Harald Anlauf via Gcc-patches" , "fortran" > Betreff: Re: [PATCH] PR fortran/100950 - ICE in output_constructor_regul= ar_field, at varasm=2Ec:5514 > > Here's now my third attempt to fix this PR, taking into account > the comments by Tobias and Bernhard=2E >=20 > > > On 10=2E06=2E21 20:52, Harald Anlauf via Fortran wrote: > > > > +static bool > > > > +substring_has_constant_len (gfc_expr *e) > > > > +{ > > > > + ptrdiff_t istart, iend; > > > > + size_t length; > > > > + bool equal_length =3D false; > > > > + > > > > + if (e->ts=2Etype !=3D BT_CHARACTER > > > > + || !e->ref > > > > + || e->ref->type !=3D REF_SUBSTRING > > >=20 > > > Is there a reason why you do not handle: > > >=20 > > > type t > > > character(len=3D5) :: str1 > > > character(len=3D:), allocatable :: str2 > > > end type > > > type(t) :: x > > >=20 > > > allocate(x%str2, source=3D"abd") > > > if (len (x%str)) /=3D 1) =2E=2E=2E > > > if (len (x%str2(1:2) /=3D 2) =2E=2E=2E > > > etc=2E > > >=20 > > > Namely: Search the last_ref =3D expr->ref->next->next =2E=2E=2E? > > > and then check that lastref? >=20 > The mentioned search is now implemented=2E >=20 > Note, however, that gfc_simplify_len still won't handle neither > deferred strings nor their substrings=2E >=20 > I think there is nothing to simplify at compile time here=2E Otherwise > there would be a conflict/inconsistency with type parameter inquiry, > see F2018:9=2E4=2E5(2): >=20 > "A deferred type parameter of a pointer that is not associated or > of an unallocated allocatable variable shall not be inquired about=2E" >=20 > > > * * * > > >=20 > > > Slightly unrelated: I think the following does not violate > > > F2018's R916 / C923 =E2=80=93 but is rejected, namely: > > > R916 type-param-inquiry is designator % type-param-name > > > the latter is 'len' or 'kind' for intrinsic types=2E And: > > > R901 designator is =2E=2E=2E > > > or substring > > > But > > >=20 > > > character(len=3D5) :: str > > > print *, str(1:3)%len > > > end > > >=20 > > > fails with > > >=20 > > > 2 | print *, str(1:3)%len > > > | 1 > > > Error: Syntax error in PRINT statement at (1) > > >=20 > > >=20 > > > Assuming you don't want to handle it, can you open a new PR? > > > Thanks! >=20 > I tried to look into this, but there appear to be several unrelated > issues requiring a separate treatment=2E I therefore opened: >=20 > https://gcc=2Egnu=2Eorg/bugzilla/show_bug=2Ecgi?id=3D101735 >=20 > > > > + istart =3D gfc_mpz_get_hwi (e->ref->u=2Ess=2Estart->value=2Eint= eger); > > > > + iend =3D gfc_mpz_get_hwi (e->ref->u=2Ess=2Eend->value=2Einteger= ); > > > > + length =3D gfc_mpz_get_hwi (e->ref->u=2Ess=2Elength->length->va= lue=2Einteger); > > > > + > > > > + if (istart <=3D iend) > > > > + { > > > > + if (istart < 1) > > > > + { > > > > + gfc_error ("Substring start index (%ld) at %L below 1", > > > > + (long) istart, &e->ref->u=2Ess=2Estart->where); > > >=20 > > > As mentioned by Bernhard, you could use HOST_WIDE_INT_PRINT_DEC=2E > > >=20 > > > (It probably only matters on Windows which uses long =3D=3D int =3D = 32bit for > > > strings longer than INT_MAX=2E) >=20 > Done=2E >=20 > The updated patch regtests fine=2E OK? >=20 > Thanks, > Harald >=20 >=20 > Fortran - simplify length of substring with constant bounds >=20 > gcc/fortran/ChangeLog: >=20 > PR fortran/100950 > * simplify=2Ec (substring_has_constant_len): New=2E > (gfc_simplify_len): Handle case of substrings with constant > bounds=2E >=20 > gcc/testsuite/ChangeLog: >=20 > PR fortran/100950 > * gfortran=2Edg/pr100950=2Ef90: New test=2E >=20 >