re PR fortran/35699 (run-time abort writing zero sized section to direct access file)
authorJerry DeLisle <jvdelisle@gcc.gnu.org>
Fri, 28 Mar 2008 22:16:29 +0000 (22:16 +0000)
committerJerry DeLisle <jvdelisle@gcc.gnu.org>
Fri, 28 Mar 2008 22:16:29 +0000 (22:16 +0000)
2008-03-28  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

PR fortran/35699
* gfortran.dg/direct_io_10.f: New test.

From-SVN: r133700

gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/direct_io_10.f [new file with mode: 0644]

index 3bd9eab567a6945ce5c107333669ccf0bc929c6d..a42d59f228ed0a01848a94a107a1e46cde124e9b 100644 (file)
@@ -1,3 +1,8 @@
+2008-03-28  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
+
+       PR fortran/35699
+       * gfortran.dg/direct_io_10.f: New test.
+
 2008-03-28  Uros Bizjak  <ubizjak@gmail.com>
 
        * gcc.target/i386/vectorize6.c: New test.
diff --git a/gcc/testsuite/gfortran.dg/direct_io_10.f b/gcc/testsuite/gfortran.dg/direct_io_10.f
new file mode 100644 (file)
index 0000000..c470272
--- /dev/null
@@ -0,0 +1,46 @@
+! { dg-do run }
+! pr35699 run-time abort writing zero sized section to direct access file
+      program directio
+      call       qi0010 (  10,   1,   2,   3,   4,  9,   2)
+      end
+
+      subroutine qi0010 (nf10, nf1, nf2, nf3, nf4,nf9, np2)
+      character(10) bda(nf10)
+      character(10) bda1(nf10), bval
+
+      integer  j_len
+      bda1(1) = 'x'
+      do i = 2,10
+        bda1(i) = 'x'//bda1(i-1)
+      enddo
+      bda = 'unread'
+
+      inquire(iolength = j_len) bda1(nf1:nf10:nf2), bda1(nf4:nf3),
+     $                               bda1(nf2:nf10:nf2)
+
+      open (unit=48,
+     $      access='direct',
+     $      status='scratch',
+     $      recl = j_len,
+     $      iostat = istat,
+     $      form='unformatted',
+     $      action='readwrite')
+
+      write (48,iostat = istat, rec = 3) bda1(nf1:nf10:nf2),
+     $                    bda1(nf4:nf3), bda1(nf2:nf10:nf2)
+      if ( istat .ne. 0) then
+        call abort
+      endif
+      istat = -314
+
+      read (48,iostat = istat, rec = np2+1) bda(nf1:nf9:nf2),
+     $                       bda(nf4:nf3), bda(nf2:nf10:nf2)
+      if ( istat .ne. 0) then
+        call abort
+      endif
+
+      do j1 = 1,10
+        bval = bda1(j1)
+        if (bda(j1) .ne. bval) call abort
+      enddo
+      end subroutine