From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by sourceware.org (Postfix) with ESMTPS id 3BE9E3885C1B; Wed, 19 Jun 2024 19:17:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3BE9E3885C1B 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 3BE9E3885C1B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=212.227.15.18 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718824662; cv=none; b=vEDN+ppTZUUUppEtrEnKiBLpDLM3qxQOB1Z3CMO8DJETPvZqBQAfjYFya0WuY3ykOjYppX5qops/OOkSmDlSrJ2mK/7HZ1rG9nrxBaKds8+SDKnWBHHPoTFPwqI1TRmqTHO1e3ZHhO/d6WSBX1/p1h5HljC+bDj2nLh80SxxZqY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718824662; c=relaxed/simple; bh=+lmMoTkgA5LHkToeJa0KBGE2yPxtL+0AN8JTa+uYjcU=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=Qd12B71BQr+oqoVTNC0D9l4nEGvb+OEc1sliRcvpFJDlXTPTuBtj52e/1apJ4VvCJYlAYRhyb2lN0k1L5Vc13JpUfPLmpL3u3o4jaURkwak7ohpOSdZSEVlhVWOHF3KcO91ZzsolzpxKHnLLFq38mO1rZrJ+OFhSETsVYlZkk+s= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1718824646; x=1719429446; i=anlauf@gmx.de; bh=B4G1uVj4CRBbNHl03DfNA8Oz9Uu21FkqrTsh4u9W52k=; h=X-UI-Sender-Class:Message-ID:Date:MIME-Version:Subject:To:Cc: 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=G3ML/fSB5wjq1MR/FVHxtEU1ziW0yYsdgo8YPZGjZGN7e5oyX+zVyHkWEXuCepKy EeFp02Nip4r6ria3ksCd4Yy4AA5UU71miwHs18n/Dmgsg5rIMV6zwIcSqBzHF0CaH 58JA0Fw2MV6eoITutmr4q8lPoJWDOwzfsPPU9dioNUQZRbMtEKI+Jd0VCZIt3Dfv9 Q11drAoTPbLopYr893yr0/tyJaK3nj2bPqtA3iOQkPA1gg1G6sJQA30ZAJyjyFVaO eo8nwcHnuxoDOFepywGydCMGHsbBMi/R7JcBCL3bOZ2XRJMvyrZX6RpgJWyO5Ne4t b6uwA6RKoO1mEDbU/w== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.178.29] ([93.207.87.49]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MStCe-1rwNnE3Dos-00NB8H; Wed, 19 Jun 2024 21:17:26 +0200 Message-ID: Date: Wed, 19 Jun 2024 21:17:23 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [Fortran, Patch, PR 96992] Fix Class arrays of different ranks are rejected as storage association argument To: Andre Vehreschild Cc: GCC-Patches-ML , GCC-Fortran-ML Newsgroups: gmane.comp.gcc.patches,gmane.comp.gcc.fortran References: <20240614170546.4180607f@vepi2> <2b124dcc-d96a-4f6b-a3a9-d730ffec29f9@gmx.de> <20240619090705.5187c71c@vepi2> Content-Language: en-US From: Harald Anlauf In-Reply-To: <20240619090705.5187c71c@vepi2> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:rSgEhk+kv9/0wWcWoPecFaf18rgFWn+kh/nzJkhilgNZHGvCJr5 Y2/vp4NdXKbJc4ts40mFllruBi9sUuYMJFLR7pz3rvseNcz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,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 Andre, Am 19.06.24 um 09:07 schrieb Andre Vehreschild: > Hi Harald, > > thank you for the investigation and useful tips. I had to figure what we= nt > wrong here, but I now figured, that the array needs repacking when a neg= ative > stride is used (or at least a call to that routine, which then fixes "st= uff"). > I have added it, freeing the memory allocated potentially by pack, and a= lso > updated the testcase to include the negative stride. hmmm, the pack does not always get generated: module foo_mod implicit none type foo integer :: i end type foo contains subroutine d1(x,n) integer, intent(in) :: n integer :: i class (foo), intent(out) :: x(n) select type(x) class is(foo) x(:)%i =3D (/ (42 + i, i =3D 1, n ) /) class default stop 1 end select end subroutine d1 subroutine d2(x,n) integer, intent(in) :: n integer :: i class (foo), intent(in) :: x(n,n,n) select type (x) class is (foo) print *,"d2: ", x%i if ( any( x%i /=3D reshape((/ (42 + i, i =3D 1, n ** 3 ) /), [n, n= , n] ))) stop 2 class default stop 3 end select end subroutine d2 subroutine d3(x,n) integer, intent(in) :: n integer :: i class (foo), intent(inout) :: x(n) select type (x) class is (foo) print *,"d3_1:", x%i x%i =3D -x%i ! Simply negate elements print *,"d3_2:", x%i class default stop 33 end select end subroutine d3 end module foo_mod program main use foo_mod implicit none type (foo), dimension(:), allocatable :: f integer :: n, k, m n =3D 2 allocate (f(n*n*n)) ! Original testcase: call d1(f,n*n*n) print *, "d1->:", f%i call d2(f,n) ! Ensure that array f is ok: print *, "d2->:", f%i ! The following shows that no appropriate internal pack is generated: call d1(f,n*n*n) print *, "d1->:", f%i m =3D n*n*n k =3D 3 print *, "->d3:", f(1:m:k)%i call d3(f(1:m:k),1+(m-1)/k) print *, "d3->:", f(1:m:k)%i print *, "full:", f%i deallocate (f) end program main After the second version of your patch this prints: d1->: 43 44 45 46 47 48 49 50 d2: 43 44 45 46 47 48 49 50 d2->: 43 44 45 46 47 48 49 50 d1->: 43 44 45 46 47 48 49 50 ->d3: 43 46 49 d3_1: 43 44 45 d3_2: -43 -44 -45 d3->: -43 46 49 full: -43 -44 -45 46 47 48 49 50 While the print properly handles f(1:m:k)%i, passing it as actual argument to subroutine d3 does not do pack/unpack. Can you have another look? Thanks, Harald > Regtests fine on x86_64-pc-linux-gnu/Fedora 39. Ok for mainline? > > Regards, > Andre > > On Sun, 16 Jun 2024 23:27:46 +0200 > Harald Anlauf wrote: > > << snipped for brevity >>> > -- > Andre Vehreschild * Email: vehre ad gmx dot de