This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, Fortran, pr60322] was: [Patch 1/2, Fortran, pr60322] [OOP] Incorrect bounds on polymorphic dummy array
- From: Dominique d'HumiÃres <dominiq at lps dot ens dot fr>
- To: Andre Vehreschild <vehre at gmx dot de>
- Cc: Paul Richard Thomas <paul dot richard dot thomas at gmail dot com>, Mikael Morin <mikael dot morin at sfr dot fr>, GCC-Fortran-ML <fortran at gcc dot gnu dot org>, GCC-Patches-ML <gcc-patches at gcc dot gnu dot org>, Antony Lewis <antony at cosmologist dot info>
- Date: Thu, 26 Mar 2015 10:26:59 +0100
- Subject: Re: [Patch, Fortran, pr60322] was: [Patch 1/2, Fortran, pr60322] [OOP] Incorrect bounds on polymorphic dummy array
- Authentication-results: sourceware.org; auth=none
- References: <20150226181717 dot 480e282c at vepi2> <551006FF dot 1080704 at sfr dot fr> <20150323134357 dot 6af740d1 at vepi2> <CAGkQGiK2sp2wqXLMPvg8bc=vgJyr9jryukvwML9Jc9+yt_9odA at mail dot gmail dot com> <20150324180620 dot 3c72960e at vepi2> <BFF75252-FD77-4C1E-A8E0-EC83BB8A9BC5 at lps dot ens dot fr> <20150325175643 dot 3b95cb42 at vepi2>
Dear Andre,
Everything works as expected with your new patch.
I have changed the test for pr57305 to
use iso_c_binding
implicit none
integer :: i
real, target :: e
class(*), allocatable, target :: a(:)
do i = 1, 3
e = i
call add_element_poly(a,e)
select type (a)
type is (real)
print *, a
end select
end do
contains
subroutine add_element_poly(a,e)
use iso_c_binding
class(*),allocatable,intent(inout),target :: a(:)
class(*),intent(in),target :: e
class(*),allocatable,target :: tmp(:)
type(c_ptr) :: dummy
interface
function memcpy(dest,src,n) bind(C,name="memcpy") result(res)
import
type(c_ptr) :: res
integer(c_intptr_t),value :: dest
integer(c_intptr_t),value :: src
integer(c_size_t),value :: n
end function
end interface
if (.not.allocated(a)) then
allocate(a(1), source=e)
else
allocate(tmp(size(a)),source=a)
deallocate(a)
allocate(a(size(tmp)+1),mold=e)
dummy = memcpy(loc(a(1)),loc(tmp),sizeof(tmp))
dummy = memcpy(loc(a(size(tmp)+1)),loc(e),sizeof(e))
end if
end subroutine
end
and get the expected outputs at run time (it works also if I replace MOLD with SOURCE and remove the second âdummy = ââ line).
Thanks for your patience,
Dominique
> Le 25 mars 2015 Ã 17:56, Andre Vehreschild <vehre@gmx.de> a Ãcrit :
>
> Hi Dominique, hi all,
>
> you are absolutely right, Dominique: I missed the part of pr60322_base_*.
>
> But this time it is there and furthermore does solve the allocate( mold=e) and
> the loc(e) issue.
>
> Paul: I have simplified your patch by only checking whether the
> arg_expr.ts.type == BT_CLASS. All tests showed, that this enough to produce the
> correct code.
>
> Bootstraps and regtests ok on x86_64-linux-gnu/F20.
>
> Comments, please!
>
> Regards,
> Andre
>
> On Wed, 25 Mar 2015 10:43:34 +0100
> Dominique d'HumiÃres <dominiq@lps.ens.fr> wrote:
- References:
- Re: [Patch 1/2, Fortran, pr60322] [OOP] Incorrect bounds on polymorphic dummy array
- Re: [Patch 1/2, Fortran, pr60322] [OOP] Incorrect bounds on polymorphic dummy array
- Re: [Patch 1/2, Fortran, pr60322] [OOP] Incorrect bounds on polymorphic dummy array
- From: Paul Richard Thomas
- [Patch, Fortran, pr60322] was: [Patch 1/2, Fortran, pr60322] [OOP] Incorrect bounds on polymorphic dummy array
- Re: [Patch, Fortran, pr60322] was: [Patch 1/2, Fortran, pr60322] [OOP] Incorrect bounds on polymorphic dummy array
- From: Dominique d'HumiÃres
- Re: [Patch, Fortran, pr60322] was: [Patch 1/2, Fortran, pr60322] [OOP] Incorrect bounds on polymorphic dummy array