This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/54618] [OOP] wrong-code with CLASS(...), INTENT(OUT) -- and OPTIONAL or ALLOCATABLE


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

Salvatore Filippone <sfilippone at uniroma2 dot it> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sfilippone at uniroma2 dot
                   |                            |it

--- Comment #18 from Salvatore Filippone <sfilippone at uniroma2 dot it> 2013-04-05 09:32:25 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]