| 1 |
! { dg-do run } |
| 2 |
! { dg-options "-std=legacy" } |
| 3 |
! |
| 4 |
! pr 16597 |
| 5 |
! libgfortran |
| 6 |
! reading a direct access record after it was written did |
| 7 |
! not always return the correct data. |
| 8 |
|
| 9 |
program gfbug4 |
| 10 |
implicit none |
| 11 |
|
| 12 |
integer strlen |
| 13 |
parameter (strlen = 4) |
| 14 |
|
| 15 |
integer iunit |
| 16 |
character string *4 |
| 17 |
|
| 18 |
iunit = 99 |
| 19 |
open (UNIT=iunit,FORM='unformatted',ACCESS='direct',RECL=strlen) |
| 20 |
write (iunit, rec=1) 'ABCD' |
| 21 |
read (iunit, rec=1) string |
| 22 |
close (iunit, status = 'delete') |
| 23 |
if (string.ne.'ABCD') STOP 1 |
| 24 |
|
| 25 |
open (UNIT=iunit,FORM='unformatted',ACCESS='direct',STATUS='scratch',RECL=strlen) |
| 26 |
write (iunit, rec=1) 'ABCD' |
| 27 |
read (iunit, rec=1) string |
| 28 |
close (iunit) |
| 29 |
if (string.ne.'ABCD') STOP 2 |
| 30 |
end |