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 D961D3858D20; Sun, 9 Jun 2024 20:35:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D961D3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmx.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D961D3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=212.227.15.15 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717965331; cv=none; b=puwcraXcTF07QIzUYqpSlP3hw4pHy1MFp21p9iQRx5LGBqExhF5U3Fe7VhXT5fM6Z9o7CuSaVS+OzuoNp0lW6Kfw6OxnkigiSJQRDoP9WPzdrK/XJ8Zt1uqceEK3pGMws8iffgq3t9OajppLjojnSQuy3K8/cRpzaGaUFJ9MBFg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717965331; c=relaxed/simple; bh=7KWL3R37AfliQv0QBngFIaFd3HkIv8zjhdujy4sWRL4=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=XhlY6/YuuwT6BO1Dy4+mgBFBpsGCn4LxxM22/Mw1RMUk/ZpRLNouVXWnkxd8gUXLTXJTZOeaCYWxwnitO50iGn+xUh3UM2mfOqImam22Pu7kJlqv87wy5S4q7jM6KotTo5PSiCEICmJXtra6il1Q5sh6RFBAnjlx0MWcuZ89XH0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1717965326; x=1718570126; i=anlauf@gmx.de; bh=5A2pvgfV4BpOHldbGukXLj0vbDe7mWGjaXNtHYNZX1Y=; h=X-UI-Sender-Class:Message-ID:Date:MIME-Version:Subject:To: References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=oiqQAjhPjeffIz3zQ1/8mOkrrvj7tTHDarbPeRQW7eQI7HEeluzdQXrgtwlqSYQL q2ESnL3u6T/Ri6vmoAVDedrt/hUAbUsZRD5jYHWKBPpbuy/Wz9RiNJqpvaHmFkyit yuV/haildaMtxsDDhcTSMMstND0/OGvIge/gVUqUoMVe7er1J9lPxBNIoct4U4YZz IXtHgAhc1uhbgxnZRf9vODpDUNkrIDz7o0OnhT6cj80NjVvE0bNolpKeA2oFblQDY z+3BCmyQIK71AM8DUFJHQZ23b5BcjtII6GKopNpN6DD+FEp+BlhNr1KqwOtJazYn0 ++i8prJUGvl7TE+wQQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.178.29] ([93.207.81.126]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MtfNl-1sZ36P2ZUF-00tIId; Sun, 09 Jun 2024 22:35:26 +0200 Message-ID: <74b99484-7cd9-4e76-a40f-2b9c844ae99f@gmx.de> Date: Sun, 9 Jun 2024 22:35:25 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [Patch, fortran] PR59104 To: Paul Richard Thomas , "fortran@gcc.gnu.org" , gcc-patches Newsgroups: gmane.comp.gcc.patches,gmane.comp.gcc.fortran References: Content-Language: en-US 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:6GzTh2HnALOXKaezIt3DK+8CN5/mnqgjsp3S2T6LcOjISNsH5eU VNuof2zws8BtInEwsQ96PBzBqIWpEdL79fzLukj/6ngKIDVe/Td/Q1Ssf0NJLNuC/hRd8Z5 OQMPafumNEYmVjQ2A+VB6x4JiWSvkGM/0h1/h2+EAVkaFDGJXEe5MHbDmO8x2HXG2RrF3J/ YzkWrZn3sr6HNwoku/5CQ== UI-OutboundReport: notjunk:1;M01:P0:jv/qRks1XII=;A+hp0Q1ehR9eLVLRNswnVogDjhr WLD1794bNmRWBdIVSkR5OJpqhiz3lovBY+bmsPy3aKdDZTxAxD050CFLGn/bb7RhgyeWKdPO4 OAxryGVkf6sYEmIw+J/+/2+jvBqu94EP28VJ9e7w9MMh/iykAQr8JorpgJskgEdww9RgxpHfT lg3ftFO6WxJKArpp7eJi9LUXyQgFR7qxg0MsvYwKP91wJ+z1YaDmWteEIREpDrq4ZVzngWMvt OT/GNcprfgcFvVlOry6RcQe9ORq/+z+ZxBbvQ8MJvpGduWgkeiZF4+nqMoAz0rr4gRki3gP/r 6TwaqctV8JEkFNKezYjvbjr3zRDUswxmap9Z77KpQSlVSiRr2y79SHq6EawHBp2drcOROGvrU VpYXQMt10k6di1KDP8dvByrDTqhZEH9IjudiN7WOanSSdRYNJ38p1c6xKbxvzgpedBbdvUTfv rO4bEApcYepDxl7fO7WFXe91ZQYMOlxKcuIdIfOA5ute5DfGh6G4FSUZSvcGOcwX1jZPoRowW 8953DudKOvISmHgEdUxwNEWN03ot4nLj2QsqOcVwFZgga3ZI2yRYNpdS8Eh0ubKKv0Ae30xrb l68cKXrbG8Z2t1/QyGUgmW5qkYC9WOw0evjSou1Eusq+CN4mEiGloommSXMMXv7KRkERY+nmb 8sCovec0GVnILXkMK1S8Obil4MF+sded6rPJz4+TxWts7vHZMYXE9QoXofIIm+/1Ul7uCr1Ul 6YRPsCd/TuPKW+aFsNoxffFzxWQKeZBaNUPC8FeaRtlbvrZKVrES7b7kxeO4v9lCwr+hlYLOI 21E9/B7eNdd0D3XFhnHEebtCuQ09j3nICG9+sX+lkZyrM= X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_NUMSUBJECT,RCVD_IN_DNSWL_LOW,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: Hi Paul, your approach sounds entirely reasonable. But as the following addition to the testcase shows, there seem to be loopholes left. When I add the following to function f: integer :: l1(size(y)) integer :: l2(size(z)) print *, size (l1), size (l2), size (z) I get: 0 0 3 Expected: 2 3 3 Can you please check? Thanks, Harald Am 09.06.24 um 17:57 schrieb Paul Richard Thomas: > Hi All, > > I have extended the testcase - see below and have > s/dependent_decls_2/dependent_decls_2.f90/ in the ChnageLog. > > Cheers > > Paul > > ! { dg-do run } > ! > ! Fix for PR59104 in which the dependence on the old style function resu= lt > ! was not taken into account in the ordering of auto array allocation an= d > ! characters with dependent lengths. > ! > ! Contributed by Tobias Burnus > ! > module m > implicit none > integer, parameter :: dp =3D kind([double precision::]) > contains > function f(x) > integer, intent(in) :: x > real(dp) f(x/2) > real(dp) g(x/2) > integer y(size (f)+1) ! This was the original problem > integer z(size (f) + size (y)) ! Found in development of the f= ix > integer w(size (f) + size (y) + x) ! Check dummy is OK > f =3D 10.0 > y =3D 1 ! Stop -Wall from complaining > z =3D 1 > g =3D 1 > w =3D 1 > if (size (f) .ne. 1) stop 1 > if (size (g) .ne. 1) stop 2 > if (size (y) .ne. 2) stop 3 > if (size (z) .ne. 3) stop 4 > if (size (w) .ne. 5) stop 5 > end function f > function e(x) result(f) > integer, intent(in) :: x > real(dp) f(x/2) > real(dp) g(x/2) > integer y(size (f)+1) > integer z(size (f) + size (y)) ! As was this. > integer w(size (f) + size (y) + x) > f =3D 10.0 > y =3D 1 > z =3D 1 > g =3D 1 > w =3D 1 > if (size (f) .ne. 2) stop 6 > if (size (g) .ne. 2) stop 7 > if (size (y) .ne. 3) stop 8 > if (size (z) .ne. 5) stop 9 > if (size (w) .ne. 9) stop 10 > end function > function d(x) ! After fixes to arrays, what was needed was known= ! > integer, intent(in) :: x > character(len =3D x/2) :: d > character(len =3D len (d)) :: line > character(len =3D len (d) + len (line)) :: line2 > character(len =3D len (d) + len (line) + x) :: line3 > line =3D repeat ("a", len (d)) > line2 =3D repeat ("b", x) > line3 =3D repeat ("c", len (line3)) > if (len (line2) .ne. x) stop 11 > if (line3 .ne. "cccccccc") stop 12 > d =3D line > end > end module m > > program p > use m > implicit none > real(dp) y > > y =3D sum (f (2)) > if (int (y) .ne. 10) stop 13 > y =3D sum (e (4)) > if (int (y) .ne. 20) stop 14 > if (d (4) .ne. "aa") stop 15 > end program p > > > > On Sun, 9 Jun 2024 at 07:14, Paul Richard Thomas < > paul.richard.thomas@gmail.com> wrote: > >> Hi All, >> >> The attached fixes a problem that, judging by the comments, has been >> looked at periodically over the last ten years but just looked to be to= o >> fiendishly complicated to fix. This is not in small part because of the >> confusing ordering of dummies in the tlink chain and the unintuitive >> placement of all deferred initializations to the front of the init chai= n in >> the wrapped block. >> >> The result of the existing ordering is that the initialization code for >> non-dummy variables that depends on the function result occurs before a= ny >> initialization code for the function result itself. The fix ensures tha= t: >> (i) These variables are placed correctly in the tlink chain, respecting >> inter-dependencies; and (ii) The dependent initializations are placed a= t >> the end of the wrapped block init chain. The details appear in the >> comments in the patch. It is entirely possible that a less clunky fix >> exists but I failed to find it. >> >> OK for mainline? >> >> Regards >> >> Paul >> >> >> >> >