| 1 |
! { dg-do run } |
| 2 |
! |
| 3 |
! Tests the fix for PR50221 |
| 4 |
! |
| 5 |
! Contributed by Clive Page <[email protected]> |
| 6 |
! and Tobias Burnus <[email protected]> |
| 7 |
! |
| 8 |
! This is from comment #2 by Tobias Burnus. |
| 9 |
! |
| 10 |
module m |
| 11 |
character(len=:), save, allocatable :: str(:) |
| 12 |
character(len=2), parameter :: const(3) = ["a1", "b2", "c3"] |
| 13 |
end |
| 14 |
|
| 15 |
use m |
| 16 |
call test() |
| 17 |
if(allocated(str)) deallocate(str) |
| 18 |
call foo |
| 19 |
contains |
| 20 |
subroutine test() |
| 21 |
call doit() |
| 22 |
! print *, 'strlen=',len(str),' / array size =',size(str) |
| 23 |
! print '(3a)', '>',str(1),'<' |
| 24 |
! print '(3a)', '>',str(2),'<' |
| 25 |
! print '(3a)', '>',str(3),'<' |
| 26 |
if (any (str .ne. const)) STOP 1 |
| 27 |
end subroutine test |
| 28 |
subroutine doit() |
| 29 |
str = const |
| 30 |
end subroutine doit |
| 31 |
subroutine foo |
| 32 |
! |
| 33 |
! This is the original PR from Clive Page |
| 34 |
! |
| 35 |
character(:), allocatable, dimension(:) :: array |
| 36 |
array = (/'xx', 'yy', 'zz'/) |
| 37 |
! print *, 'array=', array, len(array(1)), size(array) |
| 38 |
if (any (array .ne. ["xx", "yy", "zz"])) STOP 2 |
| 39 |
end subroutine |
| 40 |
end |