Fortran · 720 bytes Raw Blame History
1 ! FLUSH stress test — the gfortran killer.
2 ! Writes 1000 integers to a file, flushing after each write,
3 ! then reads them all back and verifies the sum.
4 ! This pattern causes crashes in gfortran on ARM64 due to
5 ! buffered I/O state corruption under rapid flush cycles.
6 !
7 ! CHECK: 500500
8 program test_io_flush_stress
9 implicit none
10 integer :: i, val, total
11
12 open(10, file='/tmp/afs_flush_stress.dat', status='replace')
13 do i = 1, 1000
14 write(10, *) i
15 flush(10)
16 end do
17 close(10)
18
19 total = 0
20 open(10, file='/tmp/afs_flush_stress.dat', status='old')
21 do i = 1, 1000
22 read(10, *) val
23 total = total + val
24 end do
25 close(10)
26
27 print *, total
28 end program
29