From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by sourceware.org (Postfix) with ESMTPS id 48D6A3858C50; Sun, 16 Jun 2024 21:27:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 48D6A3858C50 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 48D6A3858C50 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=212.227.17.20 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718573282; cv=none; b=ajz665fxsgsJkrvhOlWvyu0cuZWLGZQX5YaQINIvJxI+jt09J7T3gUG6TCFI4/OAju6OTQHSx9iD7TCDu76Aw5SEG5RXhbmFVXL2hHNnqop/if5vwIzJtjihJ7eQzZ/mvxQgNzlegkHRBf3+eiTQ1WJSnswqY46eSQehIdRN6ok= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718573282; c=relaxed/simple; bh=MJYuwmtBOz8Qs41F9CP7PjGRvdfMV4zs0Q0KGNBUXP8=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=fBtDT0rw31+NsNi5k2JIOkeuXVEuhWm/OxQqFPvWC5k8DveNaLoOuO+RiCYxX7XwvdOCgpW6gF+ZQlUEBVGomuKhpCV4d93KQVEmKn5q0/CIIA0Tr01fAYodzlS2kGFh0jypLSNlSHgOA5y7YxXPcjo5/HROkIBjcaNHOh7fyfE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1718573269; x=1719178069; i=anlauf@gmx.de; bh=Ldi+HUbaRH0IFe0PBiS5b6Ty25LI5mfP07ZmlhP8Jk0=; 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=UwpK42BgdhOqDRVDDEtLfQHNK7myWD15HrgWOrPEehozksR9xM34o4H+O9hC9DWO N1UqPsDgB45ePSpr5kzO8145aTl8cda8jiPMwqlJL/URIk8qpAtidN8DCEGMSDD1u P+IdGUOAk11HAhjjEOSBDHdxJFxpkr5AofEhgMhe/t1drS07iP0Qe05g6hUf9Fif+ PbyWhdfKJtcu1A3CgnXYbbZ90lsi25IZVF/1HMahtSTYGEgIkIpQtjBJ9XpkXpdV7 0rxYBbkwo29caGP5i9M9ljfOP/NZCZnpH/isLqDT3Rkn7EjVyoC4d6mgRy79xYLsK 8rJFDFGU9d2bzKWEZQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.178.29] ([93.207.84.21]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N3siG-1sRrKX2b1U-00z9wY; Sun, 16 Jun 2024 23:27:49 +0200 Message-ID: <2b124dcc-d96a-4f6b-a3a9-d730ffec29f9@gmx.de> Date: Sun, 16 Jun 2024 23:27:46 +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 , GCC-Patches-ML , GCC-Fortran-ML Newsgroups: gmane.comp.gcc.patches,gmane.comp.gcc.fortran References: <20240614170546.4180607f@vepi2> Content-Language: en-US From: Harald Anlauf In-Reply-To: <20240614170546.4180607f@vepi2> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:q6IRyJsxg8Oxi478vTkNy7QF0GVfoyQO8Ax20KZ3ekD/EqxcHZ7 X/HPe0oXXcpepzStFC4Q7RcvJ7JUwlAvhwIk0i7kBOD3Wbu09hcWRjydDFo+hqSBAJlo7po 7HLgdXeTbJeJVGrAJZ9p2tfuVASWSShUwxeLMNbNq4ZS7GWKZlsadupGfesyqxkHqXPhtR8 uzP/LoW4msBxMmwqIypsQ== UI-OutboundReport: notjunk:1;M01:P0:85u3gbFbjyg=;CfDrDSRYOvEecyZd52semMqlwWp qaue6HumU7TX3DOWnWVc+1gMtQUYwm330TZH9sPU584MJs8562DHRF15D12OfGOZfy/vkWQmU lKim7KDjitwY8PL4RFowXZxhfPSQychtDOQQwkFtkEPhLg9gG0SvSly4NqwxC8/PPuWhCa/3n ZiPima4yEtG2wtF7aaggzcID/IFhspiY6qyA7stIygiyaOMEsL1FtpalIpD+VdIfCJ9togVij t6rgCIJ6663cxfam5qey6f0t0LuXmNpWO0GSiNfSaSUx+GwsRtNhZJKEgeo5l6RqBts6kHl0T QfW8eYnBFEbUXGuX1A8CSyQ7v26v7g7F3xMtlOjCdGduoatIt5iA2990iP/bQ5EiiYzJo0D/N cQi85AU5EmiNdHcpVa3kQjDogQ/+Z4Z85UvpM8RSc71t89cLDSNLigF91wr44mvLzGCHVrwv3 tlUzPqjox9ghVhvAUy2sXesaHjfXfxrboVvuhSTgoiJkVTEQf1OZaHz+/y8dfH3nNT9W7/i0V HDLtNLy/4GiZIo/+JBk7StxRmt8dO92Yu/DLoUEph582ymG2uJabGafSplTgKkEwyCdh2Pxen pyqKvBkszTSn4lqLy21B9kKiC46cHsNLh9bg5uzsZHq/HlmXHFVPCg1ve03pl9wYQy9lcXOKn GU1cQGUOCN9gXcgFFimYndANJuc6RTg/4WUddU2O/D8HfR0o4D0r8BykzGuSprJqxuCr83A5p ACaLVHa42j75ghq5iWwaFF7nUFxq71aAaK2D5XNg1QgaGnsjVbeWstQ/4P3gdiv2ZO3wF9dEE dzqN7c7vu7nypgZ1xPiL/7+y52ChqF4gV9pby1xsVP+wg= X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H4,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: Message-ID: <20240616212746.YuUBTILG_01i-k917xZ0gvpBo9_pZA6Lzd0G0wZsvRI@z> Hi Andre, Am 14.06.24 um 17:05 schrieb Andre Vehreschild: > Hi all, > > I somehow got assigned to this PR so I fixed it. GFortran was ICEing bec= ause of > the ASSUME_RANK in a derived to class conversion. After fixing this, sto= rage > association was producing segfaults. The "shape conversion" of the class= array > as dummy argument was not initializing the dim 0 stride and with that gr= abbing > into the memory somewhere. This is now fixed and > > regtests fine on x86_64 Fedora 39. Ok for mainline? the patch fixes the testcase in your submission, but not the following slight variation of the main program: 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 *,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 end module foo_mod program main use foo_mod implicit none type (foo), dimension(:), allocatable :: f integer :: n n =3D 2 allocate (f(n*n*n)) ! Original testcase: call d1(f,n*n*n) call d2(f,n) ! OK call d1(f(1:n*n*n),n*n*n) print *, "After call d1(f(1:n*n*n:1),n*n*n):" print *, f%i call d2(f(1:n*n*n),n) ! OK ! Using stride -1: call d1(f(n*n*n:1:-1),n*n*n) print *, "After call d1(f(n*n*n:1:-1),n*n*n):" print *, f%i call d2(f(n*n*n:1:-1),n) ! not OK deallocate (f) end program main While this runs fine with the latest Intel compiler, gfortran including your patch prints: 43 44 45 46 47 48 49 50 After call d1(f(1:n*n*n:1),n*n*n): 43 44 45 46 47 48 49 50 43 44 45 46 47 48 49 50 After call d1(f(n*n*n:1:-1),n*n*n): 50 49 48 47 46 45 44 43 43 0 0 49 0 34244976 0 34238480 STOP 2 So while the negative stride (-1) in the call to d1 appears to work as it should, it does not work properly for the call to d2. The first array element is fine in d2, but anything else isn't. Do you see what goes wrong here? (This may be a more general, pre-existing issue in a different place.) Thanks, Harald P.S.: regarding your commit message, I think the reference to the pr in brackets should be moved to the end of the summary line, i.e. for Fortran: [PR96992] Fix rejecting class arrays of different ranks as storage association argument. the "[PR96992" should be moved. Makes it also easier to read. > I assume this patch could be fixing some other PRs with class array's pa= rameter > passing, too. If that sounds familiar, feel free to point me to them. > > Regards, > Andre > -- > Andre Vehreschild * Email: vehre ad gmx dot de