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/56691] [OOP] Allocatable array: wrong offset when passing to CLASS dummy


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56691

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|6.2.0, 7.0                  |
   Target Milestone|6.2                         |7.0
      Known to fail|                            |6.2.0

--- Comment #7 from janus at gcc dot gnu.org ---
(In reply to Dominique d'Humieres from comment #6)
> The test in comment 0 is still giving an off by 1 result (7.0 at r243758):

Right, I missed that. Sorry for closing too early. Reduced test case for the
remaining failure:


module m2
  implicit none
  type :: t_stv
    real :: f1
  end type
contains
  subroutine lcb(y)
    class(t_stv), intent(in) :: y(:)
    integer :: k
    write(*,*) 'Inside LCB: size is ',size(y)
    do k=1,size(y)
      write(*,*) 'f1: ', k, y(k)%f1
    enddo
  end subroutine
end module

program test
 use m2
 implicit none

 type(t_stv), allocatable :: work(:)

  allocate(work(4))
  work(:)%f1 = (/ 1.,2.,3.,4./)

  write(*,*) 'Call with whole array: works fine'
  call lcb(work)
  write(*,*) 'Call with array slice: off by 1'
  call lcb(work(:4))

end program


Prints:

 Call with whole array: works fine
 Inside LCB: size is            4
 f1:            1   1.00000000    
 f1:            2   2.00000000    
 f1:            3   3.00000000    
 f1:            4   4.00000000    
 Call with array slice: off by 1
 Inside LCB: size is            4
 f1:            1   2.00000000    
 f1:            2   3.00000000    
 f1:            3   4.00000000    
 f1:            4   0.00000000

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