| 1 |
! { dg-do run } |
| 2 |
! Test that allocatable characters with deferred length |
| 3 |
! are written correctly |
| 4 |
program main |
| 5 |
implicit none |
| 6 |
integer:: i |
| 7 |
integer, parameter:: N = 10 |
| 8 |
character(len=:), dimension(:),allocatable:: ca |
| 9 |
character(len=50):: buffer, line |
| 10 |
allocate(character(len=N):: ca(3)) |
| 11 |
buffer = "foo bar xyzzy" |
| 12 |
ca(1) = "foo" |
| 13 |
ca(2) = "bar" |
| 14 |
ca(3) = "xyzzy" |
| 15 |
write (unit=line, fmt='(3A5)') (ca(i),i=1,3) |
| 16 |
if (line /= buffer) STOP 1 |
| 17 |
ca(1) = "" |
| 18 |
ca(2) = "" |
| 19 |
ca(3) = "" |
| 20 |
read (unit=line, fmt='(3A5)') (ca(i),i=1,3) |
| 21 |
if (line /= buffer) STOP 2 |
| 22 |
end program |
| 23 |
|