https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123747
Steve Kargl <kargl at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargl at gcc dot gnu.org
--- Comment #4 from Steve Kargl <kargl at gcc dot gnu.org> ---
Here's a reduced testcase. See embedded comment. Fun with pointers!
module m1
character(1), target :: ta(3,2)=reshape((/'a','b','c','d','e','f'/),(/3,2/))
character(:), pointer :: pa(:,:)
character(2), target ::
ta2(2,3)=reshape((/'aa','bb','cc','dd','ee','ff'/),(/2,3/))
end
subroutine s1
use m1
call ss1(pa)
contains
subroutine ss1(pa)
character(:), pointer :: pa(:,:)
pa => fa(1)
print *, len(pa), size(pa), shape(pa)
!
! If either of the 2 following lines is commented out, then
! the code compiles and executes. The print statement in the
! function fa() gives
! ' 1 6 3 2',
! which is the expected output. The above print statement gives
! ' 0 6 3 2'. The length parameter
! for the result variable, which is set withing the function, is
! not passed back to the subroutine.
!
if (len(pa(:,:)(:)) /= 1 ) print *, 'error-11-b', len(pa(:,:)(:))
write(103,*,delim='quote') 4, pa(:,:)(:)
end subroutine
function fa(i) result(r)
character(i), pointer :: r(:,:)
if (i == 1) then
r => ta
else
r => ta2
end if
print *, len(r), size(r), shape(r)
end function
end subroutine s1
program foo
call s1
end program foo