| 1 |
! { dg-do run } |
| 2 |
! PR38119 - The scalarizer got the loop size wrong |
| 3 |
! for the temporary coming from the call to 'same'. |
| 4 |
! |
| 5 |
! Contributed by Mikael Morin <[email protected]> |
| 6 |
! based on a program by Vivek Rao. |
| 7 |
! |
| 8 |
module bar |
| 9 |
implicit none |
| 10 |
character(len = 2) :: c(1) |
| 11 |
contains |
| 12 |
elemental function trim_append (xx,yy) result(xy) |
| 13 |
character (len = *), intent(in) :: xx,yy |
| 14 |
character (len = len (xx) + len (yy)) :: xy |
| 15 |
xy = trim (xx) // trim (yy) |
| 16 |
end function trim_append |
| 17 |
function same(xx) result(yy) |
| 18 |
character (len = *), intent(in) :: xx(:) |
| 19 |
character (len = len (xx)) :: yy(size (xx)) |
| 20 |
yy = xx |
| 21 |
end function same |
| 22 |
subroutine xmain() |
| 23 |
c = trim_append(["a"],same(["b"])) ! The problem occurred here |
| 24 |
end subroutine xmain |
| 25 |
end module bar |
| 26 |
use bar |
| 27 |
call xmain |
| 28 |
if (c(1) .ne. "ab") STOP 1 |
| 29 |
end |