public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/23321] New: Direct unformatted read beyond EOF cores
@ 2005-08-11  0:30 bsp at kithrup dot com
  2005-08-11 13:31 ` [Bug libfortran/23321] " pinskia at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: bsp at kithrup dot com @ 2005-08-11  0:30 UTC (permalink / raw)
  To: gcc-bugs

c  Summary: Direct unformatted read beyond EOF cores

c  This program demonstrates a bug in gfortran/libgfortran.
c  The bug is that a
c  program dumps core when reading beyond the end of
c  a access='direct', form='unformatted' file instead
c  of transfering control to 'err=' label.
c  Also, returns incorrectly when reading at end of file.

c  To test
c    dd if=/dev/zero of=shortfile bs=11811 count=1
c    ./a.out
c    Bus error (core dumped)
c    dd if=/dev/zero of=shortfile bs=11812 count=1
c    ./a.out
c    should not get here
c    before 779 inbuf(1)=   32
c    STOP 0

c    Note: in the above case, the value of inbuf(1) got set to a space

c  When compiled with ifort or g77, the correct output is produced
c  in both cases.
c    ./a.out
c    at 779, all is good

c  Problem occurs in
c    GNU Fortran 95 (GCC 4.0.1)
c    GNU Fortran 95 (GCC 4.0.2 20050804 (prerelease))
c    GNU Fortran 95 (GCC 4.1.0 20050806 (experimental))

c gfortran -v
c Using built-in specs.
c Target: i686-pc-linux-gnu
c Configured with: ../../NetSrc/gcc-4.1-20050806/configure --prefix=/home/bswift/afrl/
builddev/NetInst/gcc-4.1-20050806 --enable-languages=c,f95 --with-gmp=/home/bswift/afrl/
builddev/NetInst/gmp-4.1.4 --with-mpfr=/home/bswift/afrl/builddev/NetInst/mpfr-2.1.2
c Thread model: posix
c gcc version 4.1.0 20050806 (experimental)

      implicit none

      integer    nbytes

      integer inbuflen
      parameter (inbuflen=32768)
      integer*1      inbuf(inbuflen)
      integer k

      inbuf(1)=5

      nbytes=11812

      open(35,file='shortfile',access='direct',recl=nbytes,form
     $     ='unformatted')

      read(35,rec=2,err=779) (inbuf(k),k=1,nbytes)

      write(*,*) 'should not get here'
      write(*,*) 'before 779 inbuf(1)=',inbuf(1)
      stop
 779  write(*,*) 'at 779, all is good'
      end

-- 
           Summary: Direct unformatted read beyond EOF cores
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libfortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bsp at kithrup dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23321


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-09-04 21:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-11  0:30 [Bug libfortran/23321] New: Direct unformatted read beyond EOF cores bsp at kithrup dot com
2005-08-11 13:31 ` [Bug libfortran/23321] " pinskia at gcc dot gnu dot org
2005-08-14 21:39 ` tkoenig at gcc dot gnu dot org
2005-08-15 22:32 ` tkoenig at gcc dot gnu dot org
2005-09-04 20:37 ` cvs-commit at gcc dot gnu dot org
2005-09-04 20:45 ` cvs-commit at gcc dot gnu dot org
2005-09-04 20:50 ` tkoenig at gcc dot gnu dot org
2005-09-04 21:26 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).