| 1 |
! { dg-do run } |
| 2 |
! PR 62242 |
| 3 |
! Array constructor with an array element whose value is a |
| 4 |
! character function that is described in an interface block and which |
| 5 |
! has an assumed-length result |
| 6 |
module gfbug |
| 7 |
implicit none |
| 8 |
INTERFACE |
| 9 |
function UpperCase(string) result(upper) |
| 10 |
character(*), intent(IN) :: string |
| 11 |
character(LEN(string)) :: upper |
| 12 |
end function |
| 13 |
function f2(string) result(upper) |
| 14 |
character(*), intent(IN) :: string |
| 15 |
character(5) :: upper |
| 16 |
end function |
| 17 |
END INTERFACE |
| 18 |
contains |
| 19 |
subroutine s1 |
| 20 |
character(5) c |
| 21 |
character(5), dimension(1) :: ca |
| 22 |
character(5), dimension(1) :: cb |
| 23 |
c = "12345" |
| 24 |
ca = (/f2(c)/) ! This works |
| 25 |
!print *, ca(1) |
| 26 |
cb = (/Uppercase(c)/) ! This gets an ICE |
| 27 |
if (ca(1) .ne. cb(1)) then |
| 28 |
STOP 1 |
| 29 |
end if |
| 30 |
!print *, ca(1) |
| 31 |
end subroutine |
| 32 |
end module gfbug |
| 33 |
|
| 34 |
function UpperCase(string) result(upper) |
| 35 |
character(*), intent(IN) :: string |
| 36 |
character(LEN(string)) :: upper |
| 37 |
upper = string |
| 38 |
end function |
| 39 |
function f2(string) result(upper) |
| 40 |
character(*), intent(IN) :: string |
| 41 |
character(5) :: upper |
| 42 |
upper = string |
| 43 |
end function |
| 44 |
|
| 45 |
program main |
| 46 |
use gfbug |
| 47 |
call s1 |
| 48 |
end program |