From: "Dominique d'Humières" <dominiq@lps.ens.fr>
To: Andre Vehreschild <vehre@gmx.de>
Cc: Paul Richard Thomas <paul.richard.thomas@gmail.com>,
Mikael Morin <mikael.morin@sfr.fr>,
GCC-Fortran-ML <fortran@gcc.gnu.org>,
GCC-Patches-ML <gcc-patches@gcc.gnu.org>,
Antony Lewis <antony@cosmologist.info>
Subject: Re: [Patch, Fortran, pr60322] was: [Patch 1/2, Fortran, pr60322] [OOP] Incorrect bounds on polymorphic dummy array
Date: Thu, 26 Mar 2015 09:27:00 -0000 [thread overview]
Message-ID: <2E95FE29-6605-4054-91DB-C00249F6850F@lps.ens.fr> (raw)
In-Reply-To: <20150325175643.3b95cb42@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:
next prev parent reply other threads:[~2015-03-26 9:27 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-26 17:19 Andre Vehreschild
2015-03-23 12:29 ` Mikael Morin
2015-03-23 12:44 ` Andre Vehreschild
2015-03-23 14:58 ` Mikael Morin
2015-03-23 15:49 ` Andre Vehreschild
2015-03-23 19:28 ` Mikael Morin
2015-03-24 10:13 ` Paul Richard Thomas
2015-03-24 17:06 ` [Patch, Fortran, pr60322] was: " Andre Vehreschild
2015-03-25 9:43 ` Dominique d'Humières
2015-03-25 16:57 ` Andre Vehreschild
2015-03-26 9:27 ` Dominique d'Humières [this message]
2015-03-27 12:48 ` Paul Richard Thomas
2015-04-05 9:13 ` Paul Richard Thomas
2015-04-09 12:37 ` Andre Vehreschild
2015-04-14 17:01 ` [Patch, Fortran, pr60322, addendum] " Andre Vehreschild
2015-04-16 19:13 ` Paul Richard Thomas
2015-04-23 11:34 ` [commited, Patch, " Andre Vehreschild
2015-04-27 17:43 ` Andre Vehreschild
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2E95FE29-6605-4054-91DB-C00249F6850F@lps.ens.fr \
--to=dominiq@lps.ens.fr \
--cc=antony@cosmologist.info \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=mikael.morin@sfr.fr \
--cc=paul.richard.thomas@gmail.com \
--cc=vehre@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).