2009-10-05 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gfortran.dg / backspace_6.f
blob90affdc77913933e0aa2007c0221ca76d4bc513a
1 !{ dg-do run { target fd_truncate } }
2 ! PR26464 File I/O error related to buffering and BACKSPACE
3 ! Test case derived from case by Dale Ranta.
4 ! Submitted by Jerry DeLisle <jvdelisle@gcc.gnu.org>
5 program test
6 integer,parameter :: datasize = 5000
7 dimension idata(datasize)
8 idata = -42
9 open (11, status="scratch", form="unformatted")
10 idata(1) = -1
11 idata(datasize) = -2
12 write(11)idata
13 idata(1) = -2
14 idata(datasize) = -3
15 write(11)idata
16 idata(1) = -3
17 idata(datasize) = -4
18 write(11)idata
19 backspace 11
20 backspace 11
21 idata(1) = -2
22 idata(datasize) = -3
23 write(11)idata
24 read(11,end= 1003 )idata
25 call abort()
26 1003 continue
27 backspace 11
28 backspace 11
29 read(11,end= 1004 )idata
30 if(idata(1).ne.-2 .or.idata(datasize).ne.-3) call abort()
31 stop
32 1004 continue
33 end