public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "sfilippone at uniroma2 dot it" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/54618] [OOP] wrong-code with CLASS(...), INTENT(OUT) -- and OPTIONAL or ALLOCATABLE
Date: Fri, 05 Apr 2013 09:33:00 -0000	[thread overview]
Message-ID: <bug-54618-4-k8LkQ8gxlT@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-54618-4@http.gcc.gnu.org/bugzilla/>


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54618

--- Comment #19 from Salvatore Filippone <sfilippone at uniroma2 dot it> 2013-04-05 09:33:18 UTC ---
(In reply to comment #17)
Hi,
I am seeing intermittent issues with CLASS,ALLOCATABLE,INTENT(OUT) variables
that have a CLASS,ALLOCATABLE component; however when I tried to reduce to the
following test code, it segfaults on the inner clone, whereas the full code
only fails on the outer code. In any case, the attached code is supposed to
work, and it fails  (under 4.7.2, 4.8.0 and trunk)
===============================================
module base_inner
  type inner 
    integer, allocatable :: iv(:)
  contains
    procedure, pass(val) :: clone => inner_clone
  end type inner

contains
  subroutine inner_clone(val,res)
    class(inner) :: val
    class(inner), allocatable, intent(out) :: res

    allocate(inner :: res)
    res%iv = val%iv
  end subroutine inner_clone
end module base_inner
module base_outer
  use base_inner
  type outer
    class(inner), allocatable :: inn
  contains
    procedure, pass(val) :: clone => outer_clone
  end type outer

contains
  subroutine outer_clone(val,res)
    class(outer) :: val
    class(outer), allocatable, intent(out) :: res

    allocate(outer :: res)
    call val%inn%clone(res%inn)
  end subroutine outer_clone
end module base_outer

program testclass

  use base_outer

  class(inner), allocatable :: inner1, inner2
  class(outer), allocatable :: outer1, outer2

  allocate(inner :: inner1)
  allocate(inner1%iv(3))
  call inner1%clone(inner2)
  write(0,*) allocated(inner1),allocated(inner2)

  allocate(outer :: outer1)
  allocate(inner :: outer1%inn)
  allocate(outer1%inn%iv(3))
  call outer1%clone(outer2)
  write(0,*) allocated(outer1),allocated(outer2)


end program testclass


  parent reply	other threads:[~2013-04-05  9:33 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-18 15:24 [Bug fortran/54618] New: " burnus at gcc dot gnu.org
2012-09-19  8:18 ` [Bug fortran/54618] " burnus at gcc dot gnu.org
2012-09-19 13:31 ` burnus at gcc dot gnu.org
2012-09-19 17:31 ` burnus at gcc dot gnu.org
2012-09-19 20:18 ` mikael at gcc dot gnu.org
2012-09-22 17:07 ` burnus at gcc dot gnu.org
2012-09-23  6:49 ` burnus at gcc dot gnu.org
2012-09-24 19:05 ` burnus at gcc dot gnu.org
2012-09-25 14:20 ` burnus at gcc dot gnu.org
2012-09-25 18:37 ` burnus at gcc dot gnu.org
2012-09-26  5:51 ` burnus at gcc dot gnu.org
2012-09-30 12:51 ` dominiq at lps dot ens.fr
2012-09-30 17:01 ` burnus at gcc dot gnu.org
2012-09-30 18:02 ` burnus at gcc dot gnu.org
2012-10-03 14:20 ` burnus at gcc dot gnu.org
2012-10-03 17:32 ` burnus at gcc dot gnu.org
2012-10-16 13:02 ` burnus at gcc dot gnu.org
2012-10-16 13:13 ` burnus at gcc dot gnu.org
2013-04-05  9:32 ` sfilippone at uniroma2 dot it
2013-04-05  9:33 ` sfilippone at uniroma2 dot it [this message]
2013-04-05 11:35 ` burnus at gcc dot gnu.org
2013-04-05 12:29 ` sfilippone at uniroma2 dot it

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=bug-54618-4-k8LkQ8gxlT@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).