1! { dg-do run { target fd_truncate } }
2! PR19451
3! Writing to a non-empty readonly file caused a segfault.
4! We were still trying to write the EOR after an error ocurred
5program prog
6  open (unit=10, file='PR19451.dat')
7  write (10,*) "Hello World"
8  close (10)
9  open (unit=10, file='PR19451.dat', action="read")
10  write (10,*,err=20) "Hello World"
11  call abort()
12  20 close (10, status='delete')
13end program
14
15